-
Notifications
You must be signed in to change notification settings - Fork 31
/
webpack.config.js
38 lines (30 loc) · 1002 Bytes
/
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
const webpack = require('webpack');
const { env } = require('process');
const isProd = env.NODE_ENV === 'production';
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const isNonNil = x => x != null;
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const isProfile = env.PROFILE == 'true';
const minify = env.MINIFY == 'true';
const package = require('./package.json');
const camelcase = require('camelcase');
let conf = {
entry: './src/index.js',
devtool: isProd ? false : 'inline-source-map',
output: {
filename: './build/bundle.js',
library: camelcase( package.name ),
libraryTarget: 'umd'
},
externals: isProd ? Object.keys( package.dependencies || {} ) : [],
module: {
rules: [
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader' }
]
},
plugins: [
new webpack.EnvironmentPlugin(['NODE_ENV']),
minify ? new UglifyJSPlugin() : null
].filter( isNonNil )
};
module.exports = conf;