UNPKG

1.08 kBJavaScriptView Raw
1const webpack = require('webpack')
2const path = require('path')
3const package = require('./package.json')
4
5const env = process.env.NODE_ENV
6const config = {
7 entry: './src/bin.js',
8 target: 'node', // INIT-FIXME: set this for node environments, or leave out for web.
9 externals: {
10 lodash: true
11 },
12 module: {
13 loaders: [
14 { test: /\.js$/, loader: 'babel-loader', exclude: /node_modules/ }
15 ]
16 },
17 output: {
18 libraryTarget: 'umd',
19 filename: `dist/${package.name}${env === 'production' ? '.min' : ''}.js`
20 },
21 plugins: [
22 new webpack.optimize.OccurrenceOrderPlugin(),
23 new webpack.DefinePlugin({
24 'process.env.NODE_ENV': JSON.stringify(env)
25 })
26 ]
27}
28
29if (env === 'production') {
30 config.plugins.push(
31 new webpack.optimize.UglifyJsPlugin({
32 compressor: {
33 pure_getters: true,
34 unsafe: true,
35 unsafe_comps: true,
36 warnings: false,
37 screw_ie8: false
38 },
39 mangle: {
40 screw_ie8: false
41 },
42 output: {
43 screw_ie8: false
44 }
45 })
46 )
47}
48
49module.exports = config