forked from paulstatezny/decisive
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
94 lines (86 loc) · 2.63 KB
/
Copy pathwebpack.config.js
File metadata and controls
94 lines (86 loc) · 2.63 KB
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
92
93
94
var Webpack = require('webpack');
var HtmlWebpack = require('html-webpack-plugin');
var path = require('path');
var environment = (process.env.APP_ENV || 'development');
var npmPath = path.resolve(__dirname, 'node_modules');
var config = {
entry : ['./application/bootstrap.jsx'],
plugins : [
new HtmlWebpack({template : './application/index.html'}),
new Webpack.DefinePlugin({
__BACKEND__ : process.env.BACKEND ? '\'' + process.env.BACKEND + '\'' : undefined,
__ENVIRONMENT__ : '\'' + environment + '\''
})
],
reactLoaders : ['babel']
};
if (environment === 'development') {
config.entry = [
'webpack/hot/dev-server',
'webpack-dev-server/client?http://localhost:9000'
].concat(config.entry);
config.reactLoaders = ['react-hot'].concat(config.reactLoaders);
config.plugins.push(new Webpack.HotModuleReplacementPlugin());
}
if (environment !== 'production') {
config.devtools = '#inline-source-map';
}
console.log('Environment: ' + environment);
module.exports = {
name : 'browser bundle',
entry : config.entry,
output : {
filename : 'app.js',
path : path.resolve(__dirname, 'build'),
publicPath : '/'
},
module : {
preLoaders : [
{
test : /\.js$/,
loader : 'jshint-loader',
exclude : npmPath
},
{
test : /\.jsx$/,
loader : 'jsxhint-loader',
exclude : npmPath
}
],
loaders : [
{
test : /\.(eot|ico|ttf|woff|woff2)$/,
loader : 'file-loader',
query : {name : '[path][name].[ext]'}
},
{
test : /\.(js|jsx)$/,
loaders : config.reactLoaders,
exclude : npmPath
},
{
test : /\.(gif|jpe?g|png|svg)$/i,
loaders : ['image?bypassOnDebug&optimizationLevel=7&interlaced=false']
},
{
test : /\.css$/,
loaders : ['style', 'css']
}
]
},
plugins : config.plugins,
resolve : {
extensions : ['', '.css', '.js', '.json', '.jsx']
},
devtool : config.devtools,
jshint : {
esnext : true,
globalstrict : true,
globals : {
__BACKEND__ : true,
__ENVIRONMENT__ : true,
console : true,
window : true
}
}
};