1 | const webpack = require('webpack')
|
2 | const path = require('path')
|
3 | const package = require('./package.json')
|
4 |
|
5 | const env = process.env.NODE_ENV
|
6 | const config = {
|
7 | entry: './src/bin.js',
|
8 | target: 'node',
|
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 |
|
29 | if (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 |
|
49 | module.exports = config
|