-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.dev.config.js
63 lines (62 loc) · 1.92 KB
/
webpack.dev.config.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
const path = require('path');
const webpack = require('webpack');
const autoprefixer = require('autoprefixer');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const HappyPack = require('happypack');
const happyThreadPool = HappyPack.ThreadPool({ size: 10 });
module.exports = {
debug: true,
entry: {
app: [ 'react-hot-loader/patch', path.resolve('app/scripts/index.js'), path.resolve('app/styles/app.sass') ],
},
output: {
path: path.resolve('dist'),
filename: '[name].bundle.js',
publicPath: '/',
},
module: {
loaders: [{
test: /\.sass$/,
include: path.resolve('app/styles'),
loader: 'happypack/loader?id=sass',
}, {
test: /\.js$/,
include: path.resolve('app/scripts'),
loader: 'happypack/loader?id=js',
}],
},
postcss: () => [ autoprefixer({ browsers: [ 'last 2 versions' ] }) ],
plugins: [
new HappyPack({
id: 'sass',
loaders: [ 'style', 'css?sourceMap', 'postcss?sourceMap=inline', 'sass?sourceMap' ],
threadPool: happyThreadPool,
}),
new HappyPack({
id: 'js',
loaders: [ 'babel' ],
threadPool: happyThreadPool,
}),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('development'),
},
}),
new HtmlWebpackPlugin({
filename: 'index.html',
template: path.resolve('app/index.html'),
inject: true,
}),
new webpack.HotModuleReplacementPlugin(),
],
devtool: 'cheap-eval-source-map',
devServer: {
contentBase: path.resolve('dist'),
hot: true,
historyApiFallback: {
rewrites: [
{ from: /\.[a-z0-9]{2,4}$/i, to(result) { return result.parsedUrl.pathname; } },
],
},
},
};