-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwebpack.config.prod.babel.js
More file actions
116 lines (110 loc) · 2.68 KB
/
webpack.config.prod.babel.js
File metadata and controls
116 lines (110 loc) · 2.68 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import path from 'path'
import AssetsPlugin from 'assets-webpack-plugin'
import autoprefixer from 'autoprefixer'
import ExtractTextPlugin from 'extract-text-webpack-plugin'
import UglifyJSPlugin from 'uglifyjs-webpack-plugin'
import webpack from 'webpack'
export default {
bail: true,
entry: [
path.join(__dirname, 'src/shared/nt-styles/base.styl'),
path.join(__dirname, 'src/client/client.prod.js'),
],
output: {
path: path.join(__dirname, 'static', 'build'),
publicPath: '/build/',
filename: '[name]-[chunkhash].js',
chunkFilename: '[name]-[chunkhash].chunk.js',
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules|\.git/,
loader: 'babel-loader',
options: {
babelrc: false,
presets: [
[ 'es2015', { modules: false } ],
'react',
'stage-2',
],
},
},
{
test: /\.(eot|svg|ttf|woff|woff2)$/,
loader: 'file-loader'
},
{
test: /\.css$/,
exclude: /node_modules/,
loader: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: 'css-loader',
}),
},
{
test: /\.styl$/,
exclude: /node_modules/,
loader: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{
loader: 'css-loader',
options: {
modules: true,
importLoaders: 2,
localIdentName: '[name]__[local]___[hash:base64:5]',
minimize: true,
},
},
'postcss-loader',
{
loader: 'stylus-loader',
options: {
includePaths: [ path.join(__dirname, 'src/shared/styles') ]
}
},
],
}),
},
],
},
resolve: {
extensions: [
'.json',
'.js',
],
modules: [
path.join(__dirname, 'src'),
path.join(__dirname, 'node_modules'),
],
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production'),
BROWSER: JSON.stringify(true),
},
}),
new UglifyJSPlugin(),
new ExtractTextPlugin({
filename: '[name]-[contenthash].css',
allChunks: true,
}),
new AssetsPlugin({
filename: 'assets.json',
path: path.join(__dirname, 'static'),
prettyPrint: true,
}),
new webpack.LoaderOptionsPlugin({
test: /\.styl$/,
options: {
context: __dirname,
postcss: [
autoprefixer({ browsers: [ '> 5%', 'IE > 10', 'last 2 versions' ] })
]
}
})
],
}