forked from zemlanin/blackwidow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
62 lines (58 loc) · 1.54 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
var webpack = require('webpack')
var ExtractTextPlugin = require('extract-text-webpack-plugin')
var dependencies = require('package.json').dependencies
var config
if (process.env.NODE_ENV === 'production') {
config = process.env.BWD_CONFIG
} else {
config = process.env.BWD_CONFIG || 'config/example.json'
}
var plugins = [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development'),
'config': JSON.stringify(config),
}),
new webpack.optimize.CommonsChunkPlugin('core', 'js/core.js'),
new ExtractTextPlugin('css/[name].css', {allChunks: true}),
]
if (process.env.NODE_ENV === 'production') {
plugins.push(new webpack.optimize.UglifyJsPlugin({warnings: false}))
}
module.exports = {
entry: {
core: Object.keys(dependencies),
cast: 'cast',
main: 'main',
},
output: {
path: 'dist/',
publicPath: '',
filename: 'js/[name].js',
},
module: {
preLoaders: [
// {test: /\.js$/, exclude: /node_modules/, loader: 'standard'},
],
loaders: [
{test: /\.js$/, exclude: /node_modules/, loader: 'babel'},
{test: /\.json$/, loader: 'json5-loader'},
{test: /\.css$/, loader: ExtractTextPlugin.extract(
'style-loader',
'css-loader?-url' + (process.env.NODE_ENV === 'production' ? ',minimize' : '')
)},
],
},
resolve: {
modulesDirectories: [
'src',
'src/js',
__dirname,
'node_modules',
],
extensions: ['.js', '.css', ''],
alias: {
config: config,
},
},
plugins: plugins,
}