-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.dev.config.js
91 lines (90 loc) · 2.69 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
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
const path = require('path');
const webpack = require('webpack');
const postcssAutoreset = require('postcss-autoreset');
const postcssInitial = require('postcss-initial');
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/app.js'), path.resolve('app/styles/globals.sass') ],
},
output: {
path: path.resolve('dist'),
filename: '[name].bundle.js',
publicPath: '/',
},
resolve: {
alias: {
vendor: path.resolve('vendor'),
},
},
module: {
loaders: [{
test: /\.sass$/,
include: path.resolve('app/styles/globals.sass'),
loader: 'happypack/loader?id=sass',
}, {
test: /\.sass$/,
include: path.resolve('app/styles'),
exclude: path.resolve('app/styles/globals.sass'),
loader: 'happypack/loader?id=sassModules',
}, {
test: /\.js$/,
include: path.resolve('app/scripts'),
loader: 'happypack/loader?id=js',
}],
},
postcss: () => [
postcssAutoreset({
reset: {
all: 'initial',
boxSizing: 'border-box',
},
}),
postcssInitial({
replace: true,
}),
autoprefixer({ browsers: [ 'last 2 versions' ] })
],
plugins: [
new HappyPack({
id: 'sass',
loaders: [ 'style', 'css?sourceMap', 'postcss?sourceMap=inline', 'sass?sourceMap' ],
threadPool: happyThreadPool,
}),
new HappyPack({
id: 'sassModules',
loaders: [
'style',
'css?modules&importLoaders=2&camelCase&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,
},
};