-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.vendors.js
More file actions
87 lines (82 loc) · 1.87 KB
/
webpack.vendors.js
File metadata and controls
87 lines (82 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
require('dotenv').config()
const
webpack = require('webpack'),
path = require('path'),
conf = require('dotenv').config({path: './webpack.env'}),
webroot = process.env.PUBLIC_PATH
// WebpackPlugins
const
MiniCssExtractPlugin = require("mini-css-extract-plugin"),
TerserPlugin = require('terser-webpack-plugin'),
{ CleanWebpackPlugin } = require('clean-webpack-plugin')
// settings
const
rules = require('./webpack.rules.js'),
optimization =
{
minimize: true,
minimizer: [new TerserPlugin({
terserOptions: {
keep_classnames: true,
keep_fnames: true
},
})]
},
plugins = (prefix) => {
return [
new webpack.DefinePlugin({
BASE_URL: JSON.stringify(process.env.BASE_URL)
}),
new MiniCssExtractPlugin({
filename: 'css/'+prefix+'/[name].min.css',
})
]
},
entry = (prefix) =>
{
// play here with prefix and output...
let entry =
{
vendors: [
'./resources/assets/'+prefix+'/vendors.js',
'./resources/assets/'+prefix+'/assets/scss/vendors.scss'
],
}
return entry
}
// configs
const
prefixes = ['front','admin'],
configs = prefixes.map(prefix => {
return {
cache: false,
mode: 'production',
name: 'vendors-'+prefix,
entry: entry(prefix),
output: {
path: path.resolve(__dirname, 'webroot'),
publicPath: webroot,
filename: 'js/'+prefix+'/[name].min.js',
chunkFilename: 'js/'+prefix+'/components/[fullhash].[name].min.js',
libraryTarget: 'umd'
},
optimization,
module: {
rules: [
rules.babel,
rules.scss
]
},
plugins: plugins(prefix),
resolve: {
alias: {
'@': path.resolve(__dirname, 'resources/assets', prefix),
'©': path.resolve(__dirname, 'vendor'),
'vue$': 'vue/dist/vue.esm.js'
},
extensions: ['*', '.js', '.vue', '.json']
},
}
})
//console.log(configs)
module.exports = configs