/
webpack.config.js
88 lines (80 loc) · 1.83 KB
/
webpack.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
const webpack = require('webpack'),
path = require('path'),
srcPath = path.join(__dirname, 'src'),
HtmlWebpackPlugin = require('html-webpack-plugin');
const sassLoaders = [
'style',
'css',
'sass'
];
const babelSettings = {
presets:[
'react',
'es2015',
'stage-0'
]
};
process.env.NODE_ENV = 'production'
const basePlugins = [
new webpack.DefinePlugin({
__DEV__: true,
__PRODUCTION__: false,
process: {
env: {
NODE_ENV: '"dev"'
}
}
})
]
const plugins = basePlugins
module.exports = {
target: 'web',
entry: {
module: path.join(srcPath, 'app.js'),
common: ['react']
},
output: {
path: path.join(__dirname, 'build'),
publicPath: '',
filename: '[name].js'
},
resolve: {
root: srcPath,
extensions: ['', '.js'],
modulesDirectories: ['node_modules', 'src']
},
module: {
exprContextCritical: false,
loaders: [
// Babel
{
test: /\.js?$/,
exclude: /node_modules/,
loaders: ['babel?'+JSON.stringify(babelSettings)],
},
// Sass
{
test: /\.scss$/,
loaders: sassLoaders
},
// Images
{
test: /\.(png|jpg)$/,
loader: 'url-loader?limit=8192!', // inline base64 URLs for <=8k images, direct URLs for the rest
include: './images'
}
]
},
sassLoader: {
inludePaths: [path.resolve(__dirname, 'src/styles-config/')]
},
plugins: [
new HtmlWebpackPlugin({
inject: true,
template: 'src/index.html'
})
].concat(plugins),
devServer: {
contentBase: './tmp'
}
};