-
Notifications
You must be signed in to change notification settings - Fork 9
/
webpack.config.client.js
121 lines (117 loc) · 3.23 KB
/
webpack.config.client.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
const { join } = require('path');
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const autoprefixer = require('autoprefixer');
const prod = process.env.NODE_ENV === "production";
console.log(`Compiling client code with production set to "${prod}"`);
module.exports = {
entry: !prod ? (
{
bundle: ['webpack-hot-middleware/client', 'isomorphic-fetch', 'regenerator-runtime/runtime', join(__dirname, './src/utils/polyfills.js'), join(__dirname, './src/crossover/entry.js')],
}
) : (
{
bundle: [join(__dirname, './src/utils/polyfills.js'), 'isomorphic-fetch', 'regenerator-runtime/runtime', './src/crossover/entry.js'],
vendor: ['react', 'react-dom'],
}
),
target: 'web',
output: {
path: join(__dirname, 'dist'),
filename: '[name].js',
pathinfo: !prod,
publicPath: '/dist/',
},
devtool: prod ? 'source-map' : 'eval',
module: {
loaders: [
{
test: /\.(jsx?)$/,
exclude: /node_modules/,
loaders: [
'babel-loader',
],
},
{
test: /\.(jpe?g|png|gif|svg)$/i,
loaders: ['file-loader?context=src/images&name=images/[path][name].[ext]', {
loader: 'image-webpack-loader',
query: {
mozjpeg: {
progressive: true,
quality: 80,
},
gifsicle: {
interlaced: false,
},
optipng: {
optimizationLevel: 4,
},
pngquant: {
quality: '75-90',
speed: 3,
},
},
}],
exclude: /node_modules/,
include: __dirname,
},
{
test: /\.s?css/,
loader: prod ? (
ExtractTextPlugin.extract({
fallback: 'style-loader',
loader: [
'css-loader',
'postcss-loader',
'sass-loader',
],
})
) : (
'style-loader!css-loader!postcss-loader!sass-loader'
),
},
],
},
plugins: !prod ? ([
new webpack.HotModuleReplacementPlugin(),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('development'),
BABEL_ENV: JSON.stringify('client-dev'),
},
}),
new webpack.LoaderOptionsPlugin({
options: {
postcss: [autoprefixer({ browsers: ['> 1%', 'last 2 versions', 'Opera >= 12', 'Chrome >= 25', 'Firefox >= 13', 'ie >= 9'] })],
},
}),
]) : ([
new webpack.LoaderOptionsPlugin({
minimize: true,
debug: false,
}),
new webpack.optimize.UglifyJsPlugin({
beautify: false,
mangle: true,
screw_ie8: true,
compress: {
warnings: false,
drop_console: true,
},
output: {
comments: false,
},
sourceMap: false,
}),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production'),
BABEL_ENV: JSON.stringify('client-build'),
APP_ENV: JSON.stringify('browser'),
},
}),
new ExtractTextPlugin("styles.css"),
]),
};
//postcss: [autoprefixer({ browsers: ['> 1%', 'last 2 versions', 'Opera >= 12', 'Chrome >= 25', 'Firefox >= 13', 'ie >= 9'] })],