/
webpack.config.js
87 lines (82 loc) · 2.65 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
var Webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var HtmlWebpack = require('html-webpack-plugin');
var WebpackError = require('webpack-error-notification');
var environment = (process.env.APP_ENV || 'development');
var config = {
entry : ['./application/bootstrap.js'],
plugins : [
new ExtractTextPlugin('app.css', {allChunks : true}),
new HtmlWebpack({template : './application/index.html'}),
new Webpack.DefinePlugin({
__BACKEND__ : process.env.BACKEND,
__ENVIRONMENT__ : '\''+environment+'\''
})
],
reactLoaders : ['jsx?insertPragma=React.DOM'],
sassOptions : (
'?outputStyle=' + (environment === 'production' ? 'compressed' : 'nested') +
'&includePaths[]=' + __dirname + '/node_modules'
)
};
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 = config.plugins.concat([
new Webpack.HotModuleReplacementPlugin(),
new WebpackError(process.platform)
]);
}
module.exports = {
name : 'browser bundle',
entry : config.entry,
output : {
filename : 'app.js',
path : __dirname + '/build'
},
module : {
preLoaders : [
{
test : /\.js?/,
loader : 'jshint-loader',
exclude : __dirname + '/node_modules'
},
{
test : /\.jsx?/,
loader : 'jsxhint-loader',
exclude : __dirname + '/node_modules'
}
],
loaders : [
{
test : /\.(eot|ico|jpg|png|svg|ttf|woff|woff2)$/,
loader : 'file-loader',
query : {name : '[path][name].[ext]'}
},
{
test : /\.jsx$/,
loaders : config.reactLoaders,
exclude : __dirname + '/node_modules'
},
{
test : /\.json$/,
loader : 'json-loader'
},
{
test : /\.scss$/,
loader : ExtractTextPlugin.extract(
'style-loader',
'css-loader!sass-loader' + config.sassOptions
)
}
]
},
plugins : config.plugins,
resolve : {
extensions : ['', '.js', '.json', '.jsx', '.webpack.js', '.web.js']
},
devtool : '#inline-source-map',
};