-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.prod.js
65 lines (59 loc) · 1.47 KB
/
webpack.prod.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
const webpack = require('webpack');
const merge = require('webpack-merge');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const path = require('path');
const common = require('./webpack.common.js');
const APP_DIR = path.resolve(__dirname, 'src');
module.exports = (env) => (
merge(common(env), {
module: {
rules: [{
test: /\.s?[ac]ss$/,
include: APP_DIR,
use: [{
loader: MiniCssExtractPlugin.loader,
}, {
loader: 'css-loader',
options: {
minimize: true,
sourceMap: true,
},
}, {
loader: 'sass-loader',
}],
}],
},
optimization: {
splitChunks: {
cacheGroups: {
vendor: {
chunks: 'initial',
name: 'vendor',
test: 'vendor',
enforce: true,
},
},
},
runtimeChunk: true,
minimizer: [
new OptimizeCSSAssetsPlugin({}),
],
},
devtool: 'cheap-module-source-map',
stats: {
children: false,
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production'),
DOMAIN_ROOT: JSON.stringify('/cubego.io/public'),
}),
new MiniCssExtractPlugin({
filename: 'styles.css',
chunkFilename: 'styles.css',
}),
],
mode: 'production',
})
);