-
Notifications
You must be signed in to change notification settings - Fork 0
/
configureDevelopment.js
71 lines (69 loc) · 2.24 KB
/
configureDevelopment.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
var path = require('path');
var fs = require('fs');
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = function(options) {
var entry = {};
if (typeof options.entry === 'object') {
Object.keys(options.entry).forEach(function(key) {
entry[key] = [
'webpack-hot-middleware/client?noInfo=true&reload=true',
options.entry[key]
];
});
} else {
entry.app = [
'webpack-hot-middleware/client?noInfo=true&reload=true',
options.entry
];
}
return {
entry: entry,
output: {
path: path.resolve(options.root, 'build'),
filename: '[name].js',
pathinfo: true,
publicPath: '/',
// contentBase: fs.existsSync(path.resolve(options.root, 'index.html')) ? path.resolve(options.root) : __dirname
contentBase: path.resolve(options.root)
},
devtool: '#eval-source-map',
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.DefinePlugin(options.globals),
new HtmlWebpackPlugin({
title: options.package.name,
template: fs.existsSync(path.resolve(options.root, 'index.html')) ? path.resolve(options.root, 'index.html') : path.resolve(__dirname, 'index.html'),
inject: 'body',
description: options.package.description,
version: options.package.version
})
],
// Packup-specific options, not directly used by webpack
port: options.port,
loaders: {
js: {
loader: 'babel',
query: {
presets: ['es2015', 'react', 'stage-2'].map((preset) => require.resolve(`babel-preset-${preset}`)),
// Need to explicitly resolve to the local module
plugins: [
[
require.resolve('babel-plugin-react-transform'),
{
transforms: [{
transform: require.resolve('react-transform-hmr'),
imports: [require.resolve('react')],
locals: ['module']
}, {
transform: require.resolve('react-transform-catch-errors'),
imports: [require.resolve('react'), require.resolve('redbox-react')]
}]
}
]
]
}
}
}
};
}