-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathwebpack.config.prod.js
100 lines (96 loc) · 2.53 KB
/
webpack.config.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var path = require('path');
var webpack = require('webpack');
module.exports = {
devtool: 'source-map',
entry: {
'app': './index.js'
},
output: {
path: path.resolve('./dist/static'),
filename: '[name].[chunkhash].js',
publicPath: '/static/'
},
resolve: {
extensions: ['', '.js', '.jsx', '.css', '.scss'],
alias: {
'SRC': __dirname + '/src'
}
},
module: {
"loaders": [
{
test: /\.jsx?/,
exclude: /node_modules/,
loader: 'babel'
},
{
test: /\.json$/,
exclude: /node_modules/,
loader: 'json-loader',
},
{
test: /\.woff(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url?limit=10000&minetype=application/font-woff',
},
{
test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url?limit=10000&minetype=application/font-woff',
},
{
test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url?limit=10000&minetype=application/octet-stream',
},
{
test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
loader: 'file',
},
{
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url?limit=10000&minetype=image/svg+xml',
},
{
test: /.*\.(gif|png|jpe?g)$/i,
loader: "url-loader?mimetype=image/png"
},
{
test: /\.scss$/,
loader: ExtractTextPlugin.extract('style-loader', 'css-loader')
// loader: 'style!css?sourceMap!autoprefixer-loader',
},
{
test: /\.css$/,
loader: ExtractTextPlugin.extract('style', 'css?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]')
// loader: 'style!css?sourceMap!autoprefixer-loader',
},
]
},
plugins: [
new ExtractTextPlugin('[name].[chunkhash].css', {
disable: false,
allChunks: true,
}),
new HtmlWebpackPlugin({
template: path.resolve(__dirname, 'index.tmpl'),
inject: true,
hash: false,
// 相对于`config.output.path`的路径
filename: '../index.html',
minify: false,
favicon: false,
}),
new webpack.IgnorePlugin(/^\.\/locale$/, [/moment$/]),
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('production')
}
}),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false,
}
})
]
};