/
webpack.config.js
57 lines (52 loc) · 1.29 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
const glob = require('glob').sync;
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const template = 'example/template.html';
const entries = glob( path.join(__dirname, 'example', '*.js') )
.reduce( (entries, name) => {
entries[path.basename(name, '.js')] = name;
return entries;
}, {});
entries['infinigrid'] = path.join(__dirname, 'src', 'index.js' );
const plugins = Object.keys(entries).map(name =>
new HtmlWebpackPlugin({template, filename: name + '.html', chunks: [name]})
);
if (process.env.NODE_ENV == 'production') {
plugins.unshift(
new webpack.DefinePlugin({ 'process.env': { NODE_ENV: JSON.stringify('production') } }),
new webpack.optimize.UglifyJsPlugin({minimize: true})
);
}
module.exports = {
entry: entries,
output: {
path: path.join(__dirname, 'build'),
filename: '[name].js',
},
devtool: 'source-map',
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel-loader'
},
],
postLoaders: [
{
test: /\.js$/,
loader: 'transform?brfs',
},
]
},
node: {
fs: 'empty',
},
plugins,
resolve: {
alias: {
infinigrid: path.join(__dirname, 'src/index.js')
}
}
};