/
webpack.config.build-baked.js
71 lines (68 loc) · 1.53 KB
/
webpack.config.build-baked.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 ChildCompilerLoaderListPlugin =
require('child-compiler-loader-list-webpack-plugin');
var DefinePlugin = require('webpack').DefinePlugin;
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var HtmlPlugin = require('html-webpack-plugin');
var UglifyJsPlugin = require('webpack').optimize.UglifyJsPlugin;
fileExtensions = ['jpg'];
var loaders = [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel-loader',
},
{
test: /\.jsx$/,
loader: 'baggage-loader?[file].styl',
},
{
test: /\.styl$/,
loader: ExtractTextPlugin.extract(
'style-loader',
'css-loader!stylus-loader'
),
},
{
test: /\.json$/,
loader: 'json-loader',
},
].concat(fileExtensions.map(function(ext) {
return {
test: new RegExp('\\.' + ext + '$'),
loader: 'file-loader',
};
}));
module.exports = {
context: __dirname,
entry: './src',
output: {
path: 'dist',
filename: '[hash].js',
},
module: {
loaders: loaders,
},
resolve: {
extensions: ['', '.js', '.jsx'],
},
plugins: [
new DefinePlugin({
BAKED: true,
}),
new ChildCompilerLoaderListPlugin({
test: /html-webpack-plugin/,
loaders: loaders
.filter(function(item) {return item.test.source !== '\\.styl$';})
.concat({
test: /\.styl$/,
loader: 'raw-loader',
}),
}),
new ExtractTextPlugin('[contenthash].css'),
new HtmlPlugin({
template: './src/index.html.bake.js',
filename: 'index.html',
}),
new UglifyJsPlugin(),
],
};