-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
78 lines (70 loc) · 1.58 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
const {join} = require('path');
const camelCase = require('lodash.camelcase');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const package = require('./package.json');
const {PORT=3030, NODE_ENV='production'} = process.env;
const base = {
entry: {
index: join(__dirname, 'src')
},
output: {
filename: '[name].js',
chunkFilename: '[name].js',
library: camelCase(package.name.split('/').slice(-1)[0]),
libraryTarget: 'umd',
path: join(__dirname, 'dist'),
},
resolve: {
extensions: ['.js', '.json']
},
module: {
rules: [
{
test: /\.js$/,
use: 'babel-loader',
exclude: [join(__dirname, 'node_modules')]
}
]
},
};
const env = {
development: {
devtool: 'source-map',
devServer: {
hot: true,
inline: true,
historyApiFallback: true,
port: PORT,
publicPath: '/',
contentBase: join(__dirname, '.'),
watchContentBase: true,
stats: {
colors: true
}
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NamedModulesPlugin(),
new HtmlWebpackPlugin({
filename: 'index.html',
template: join(__dirname, 'index.html'),
inject: 'head',
})
]
},
production: {
externals: {
'fuse.js': {
commonjs: 'fuse.js',
commonjs2: 'fuse.js',
amd: 'fuse.js',
root: 'Fuse',
},
},
plugins: [
new webpack.optimize.UglifyJsPlugin(),
]
}
};
module.exports = Object.assign({}, base, env[NODE_ENV]);