-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
45 lines (40 loc) · 1.28 KB
/
webpack.config.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
const merge = require('webpack-merge');
// const CompressionPlugin = require('compression-webpack-plugin');
const webpack = require('webpack');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const commonConfig = require('./webpack.common.config.js');
const publicConfig = {
// devtool: 'cheap-module-source-map',
// devtool: 'source-map',// devtool优化
module: {
rules: [{
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: "style-loader",
use: ["css-loader", "postcss-loader"]
})
}]
},
plugins: [
// 每次打包前自动清理下dist文件。
new CleanWebpackPlugin(['dist/*.*']),
// 压缩生成的文件。
new UglifyJSPlugin(),
// 我们可以使用 webpack 内置的 DefinePlugin 为所有的依赖定义这个变量:
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('production'),
'HOST': '""',
'API':'"/server"'
}
}),
// 单独生成css文件。
new ExtractTextPlugin({
filename: '[name].[contenthash:5].css',
allChunks: true
})
]
};
module.exports = merge(commonConfig, publicConfig);