-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
72 lines (67 loc) · 1.84 KB
/
webpack.config.js
File metadata and controls
72 lines (67 loc) · 1.84 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
var path = require('path');
var webpack = require('webpack');
var BUILD_DIR = path.resolve(__dirname, 'dist/');
var config = {
entry: [
'webpack-hot-middleware/client',
'./src/js/main.js'
],
output: {
path: BUILD_DIR,
filename: 'bundle.js'
},
plugins: [
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.HotModuleReplacementPlugin()
],
module: {
loaders: [
{
test: /\.jsx?$/,
loader: 'babel',
exclude: /(node_modules)/,
include: __dirname,
query: {
presets: ['es2015', 'react', 'stage-0']
}
},
{
test: /\.scss$/,
loaders: ['style', 'css', 'sass']
},
{
test: /\.(jpe?g|png|gif|svg)$/i,
loaders: [
'file?hash=sha512&digest=hex&name=[hash].[ext]',
'image-webpack?bypassOnDebug&optimizationLevel=7&interlaced=false'
]
}
]
},
devServer: {
historyApiFallback: true
}
};
if (process.env.HOT) {
config.devtool = 'eval';
config.entry['index.ios'].unshift('react-native-webpack-server/hot/entry');
config.entry['index.ios'].unshift('webpack/hot/only-dev-server');
config.entry['index.ios'].unshift('webpack-dev-server/client?http://localhost:8080');
config.output.publicPath = 'http://localhost:8080/';
config.plugins.unshift(new webpack.HotModuleReplacementPlugin());
// Note: enabling React Transform and React Transform HMR:
config.module.loaders[0].query.plugins.push([
'react-transform', {
transforms: [{
transform : 'react-transform-hmr',
imports : ['react'],
locals : ['module']
}]
}
]);
}
if (process.env.NODE_ENV === 'production') {
config.plugins.push(new webpack.optimize.OccurrenceOrderPlugin());
config.plugins.push(new webpack.optimize.UglifyJsPlugin());
}
module.exports = config;