-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwebpack.prod.js
More file actions
85 lines (80 loc) · 2.1 KB
/
Copy pathwebpack.prod.js
File metadata and controls
85 lines (80 loc) · 2.1 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
const webpack = require('webpack');
const path = require('path');
const webpackMerge = require('webpack-merge');
// plugins
const WebpackChunkHash = require('webpack-chunk-hash');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
// common config
const common = require('./webpack.common');
// constants
const ENV = process.env.NODE_ENV = process.env.ENV = 'production';
module.exports = webpackMerge(common.config, {
output: {
filename: '[name].[chunkhash].js',
path: path.resolve(__dirname, '../dist')
},
module: {
rules: [
{
test: /\.css$/,
use: [
'style-loader',
'css-loader?sourceMap=false&importLoaders=1&minimize=true',
{
loader: 'postcss-loader', options: {
config: {
plugins: [
require('autoprefixer')({})
]
}
}
}
],
exclude: /node_modules/
},
{
test: /\.scss$/,
use: [
'style-loader',
'css-loader?sourceMap=false&importLoaders=1&minimize=true',
'sass-loader',
{
loader: 'postcss-loader', options: {
config: {
plugins: [
require('autoprefixer')({})
]
}
}
}
],
exclude: /node_modules/
}
]
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
ENV: JSON.stringify(ENV)
}
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: module => module.context && module.context.indexOf('node_modules') !== -1
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'manifest',
minChunks: Infinity
}),
new webpack.HashedModuleIdsPlugin(),
new WebpackChunkHash(),
new webpack.LoaderOptionsPlugin({
minimize: true,
debug: false
}),
new UglifyJsPlugin()
],
devServer: {
contentBase: path.resolve(__dirname, '../dist')
}
});