-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.config.babel.js
90 lines (85 loc) · 2.13 KB
/
webpack.config.babel.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
import webpack from 'webpack';
import path from 'path';
import Dash from 'webpack-dashboard/plugin'; // eslint-disable-line
import Extracter from 'extract-text-webpack-plugin';
// postcss plugins
import cssnext from 'postcss-cssnext';
import short from 'postcss-short';
import utilities from 'postcss-utilities';
const config = {
entry: [
'react-hot-loader/patch',
'babel-polyfill',
'./src/client/index.jsx',
],
output: {
path: path.join(__dirname, 'static'),
filename: 'bundle.js',
publicPath: '/static/',
},
resolve: {
extensions: ['', '.js', '.jsx'],
},
stats: {
colors: true,
hash: false,
timings: true,
chunks: false,
chunkModules: false,
modules: false,
},
module: {
preLoaders: [
{
test: /\.jsx?$/,
loaders: ['eslint?{fix:true}'],
exclude: /(node_modules|bower_components|dist)/,
},
],
loaders: [
{
test: /\.jsx?$/,
loader: 'babel',
exclude: /(node_modules|bower_components)/,
},
{
test: /\.json$/,
loader: 'json-loader',
},
],
},
plugins: [
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.NoErrorsPlugin(),
new Extracter('styles.css'),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
}),
],
postcss() {
return [
cssnext,
short,
utilities,
];
},
};
if (process.env.NODE_ENV === 'development') {
config.entry.splice(1, 0, 'webpack-hot-middleware/client');
config.plugins.push(new webpack.HotModuleReplacementPlugin(), new Dash());
config.devtool = 'inline-source-map';
config.module.loaders.push({
test: /\.css$/,
loader: 'style-loader!' +
'css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!' +
'postcss-loader?sourceMap=inline',
});
} else {
config.module.loaders.push({
test: /\.css$/,
loader: Extracter.extract('style-loader',
'css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!' +
'postcss-loader?sourceMap=inline'),
});
}
export default config;