-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
42 lines (39 loc) · 973 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
39
40
41
42
/* eslint-env node */
const path = require('path');
const compact = require('lodash/compact');
const webpack = require('webpack');
const CleanPlugin = require('clean-webpack-plugin');
const REPO_ROOT = __dirname;
const ASSETS_PATH = path.resolve(REPO_ROOT, 'dist');
module.exports = (env) => ({
entry: './src/index.js',
output: {
path: ASSETS_PATH,
filename: 'index.js',
library: 'tt-react-calendar',
libraryTarget: 'umd',
},
externals: {
'react': {
commonjs: 'react',
commonjs2: 'react',
amd: 'react',
root: 'React',
},
'moment': {
commonjs: 'moment',
commonjs2: 'moment',
amd: 'moment',
root: 'moment',
},
},
module: {
rules: [
{test: /\.js$/, exclude: /node_modules/, loader: "babel-loader"},
],
},
plugins: compact([
new CleanPlugin([ASSETS_PATH], { root: REPO_ROOT }),
(env === 'dist:min' ? new webpack.optimize.UglifyJsPlugin() : null),
]),
})