forked from giotiskl/filterizr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
56 lines (52 loc) · 1.54 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
var HtmlWebpackPlugin = require('html-webpack-plugin');
var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
var UglifyJsPlugin = require('webpack').optimize.UglifyJsPlugin;
var DefinePlugin = require('webpack').DefinePlugin;
module.exports = env => {
const withjquery = env.withjquery;
env = env.env;
let config = {
entry: [
// set our index.js as the entry point
'./src/index',
],
output: {
path: __dirname,
filename: `./dist/jquery.filterizr${withjquery === 'true' ? '-with-jquery' : ''}.min.js`,
},
module: {
loaders: [
// JavaScript loader
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
// run JS through Babel
use: {
loader: 'babel-loader'
}
},
]
},
plugins: [
new HtmlWebpackPlugin({
title: `Filterizr demo - ${withjquery === 'true' ? 'with' : 'without'} jQuery in bundle`,
template: `demo/index${withjquery === 'true' ? '' : '-without-jquery-in-bundle'}.html`,
}),
// uglify plugin for JS
new UglifyJsPlugin(),
// Expose whether jQuery should be imported or not
new DefinePlugin({
FILTERIZR_ENV: JSON.stringify(env),
IMPORT_JQUERY: JSON.stringify(withjquery === 'true'),
}),
],
resolve: {
extensions: ['.js'],
}
}
if (env === 'analyze') {
// When the env is analyze, generate bundle analysis
config.plugins.push(new BundleAnalyzerPlugin());
}
return config;
}