-
Notifications
You must be signed in to change notification settings - Fork 24
/
webpack.config.js
45 lines (40 loc) · 1.12 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
const path = require('path');
const pkg = require('./package.json');
const camelcase = require('camelcase');
const process = require('process');
const env = process.env;
const NODE_ENV = env.NODE_ENV;
const PROD = NODE_ENV === 'production';
const SRC_DIR = './src';
let config = {
// unless we are in production, use inline-source-map development tool
// which helps track down bugs
devtool: PROD ? false : 'inline-source-map',
// entry point - src/index.js
entry: path.join(__dirname, SRC_DIR, 'index.js'),
// webpack throws warning if not provided a default mode
// use the 'build:dev' script if you want development mode with non-minified file
// this mode is used in 'build' script
mode: 'production',
output: {
path: path.join( __dirname ),
filename: pkg.name + '.js',
library: camelcase( pkg.name ),
libraryTarget: 'umd'
},
// loader
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: 'babel-loader'
}
]
},
// minimize file if mode is production
optimization: {
minimize: PROD ? true : false
}
};
module.exports = config;