This repository has been archived by the owner on May 18, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
52 lines (49 loc) · 1.48 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
46
47
48
49
50
51
52
'use strict';
const path = require('path');
const process = require('process');
const webpack = require('webpack');
const ENV = process.env.NODE_ENV === 'production';
const src = './docs/src/public';
module.exports = {
entry: {
index: path.resolve(src, './index.js'),
login: path.resolve(src, './templates/login.js'),
dashboard: path.resolve(src, './templates/dashboard.js'),
common: [
'radium',
'radium-normalize',
'prop-types',
'react',
'react-dom',
'redux',
'react-redux',
'react-router-dom'
]
},
output: {
filename: ENV ? '[name].min.js' : '[name].js',
chunkFilename: ENV ? '[name].min.js' : '[name].js',
publicPath: ENV ? '/cat-components/public/js/' : '/assets/',
path: path.resolve(__dirname, './docs/public/js')
},
module: {
rules: [
{test: /\.js$/, loader: 'babel-loader'}
]
},
plugins: ENV ? [
new webpack.DefinePlugin({'process.env': {
NODE_ENV: JSON.stringify('production'),
TYPE: JSON.stringify('client')
}}),
new webpack.optimize.CommonsChunkPlugin({name: 'common', filename: 'common.min.js'}),
new webpack.optimize.UglifyJsPlugin({sourceMap: true}),
new webpack.LoaderOptionsPlugin({minimize: true, debug: true})
] : [
new webpack.DefinePlugin({'process.env': {
TYPE: JSON.stringify('client')
}}),
new webpack.optimize.CommonsChunkPlugin({name: 'common', filename: 'common.js'}),
new webpack.HotModuleReplacementPlugin()
]
};