-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.common.js
46 lines (45 loc) · 1.1 KB
/
webpack.common.js
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
const webpack = require('webpack');
const path = require('path');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const WebpackMd5Hash = require('webpack-md5-hash');
module.exports = {
entry: {
app: './src/assets/js/app.js'
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'assets/js/[name]-[chunkhash].bundle.js'
},
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.scss$/,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'postcss-loader', 'sass-loader']
}
]
},
optimization: {
splitChunks: {
cacheGroups: {
commons: {
test: /[\\/]node_modules[\\/]/,
name: 'vendor',
chunks: 'all'
}
}
}
},
plugins: [
new CleanWebpackPlugin(['index.html', 'dist/assets/css', 'dist/assets/js']),
new MiniCssExtractPlugin({
filename: 'assets/css/[name]-[contenthash].min.css',
}),
new WebpackMd5Hash()
]
};