-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.prod.js
86 lines (76 loc) · 1.97 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
const path = require('path');
const webpack = require('webpack');
const SaveAssetsJson = require('assets-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
module.exports = {
devtool: 'source-map',
// Capture timing information for each module
profile: false,
// Switch loaders to debug mode
mode: 'production',
// Report the first error as a hard error instead of tolerating it
bail: true,
entry: ['babel-polyfill', './assets/main.jsx'],
output: {
path: path.join(__dirname, '/public/dist/'),
pathinfo: true,
publicPath: '/dist/',
filename: 'bundle.[hash].min.js'
},
resolve: {
modules: [__dirname, 'node_modules'],
alias: {
assets: 'assets',
styles: 'assets/styles',
components: 'assets/components/'
},
extensions: ['.webpack.js', '.web.js', '.js', '.jsx']
},
resolveLoader: {
modules: ['node_modules']
},
plugins: [
new CleanWebpackPlugin(['public/dist'], {
verbose: true,
dry: false
}),
new webpack.optimize.OccurrenceOrderPlugin(true),
new UglifyJsPlugin(),
new SaveAssetsJson({
path: process.cwd(),
filename: 'assets.json'
}),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production')
}
})
],
module: {
rules: [
{
test: /(\.css$)/,
loaders: ['style-loader', 'css-loader']
},
{
test: /\.scss$/,
use: [
{ loader: 'style-loader' },
{ loader: 'css-loader?sourceMap' },
{ loader: 'sass-loader?sourceMap' }
]
},
{
test: /\.(ttf|eot|svg|woff|png|jpg|gif)(\?[a-z0-9]+)?$/,
use: [{ loader: 'file-loader?name=[path][name].[ext]' }]
},
{
test: /\.jsx?$/,
exclude: /node_modules/,
use: [{ loader: 'babel-loader' }],
include: path.join(__dirname, 'assets'),
}
],
}
};