-
Notifications
You must be signed in to change notification settings - Fork 65
/
webpack.config.js
54 lines (50 loc) · 1.2 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
const path = require('path');
const webpack = require('webpack');
const merge = require('webpack-merge');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const env = process.env.NODE_ENV || 'development';
const commons = {
context: path.join(__dirname, 'src'),
entry: [ 'babel-polyfill', './index.js' ],
output: {
library: 'mysam',
libraryTarget: 'umd',
filename: path.join('dist', 'mysam.js')
},
module: {
rules: [{
test: /\.jsx?$/,
exclude: /node_modules\/(?!(@feathersjs|feathers|mysam|debug))/,
loader: 'babel-loader'
}, {
test: path.resolve(__dirname, 'node_modules/webworker-threads/index.js'),
use: 'null-loader'
}]
},
node: {
fs: 'empty'
}
};
const dev = {
devtool: 'source-map',
devServer: {
port: 3030,
contentBase: '.',
compress: true
}
};
const production = {
devtool: 'cheap-module-source-map',
output: {
filename: path.join('dist', 'mysam.min.js')
},
plugins: [
new UglifyJSPlugin({
sourceMap: false
}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production')
})
]
};
module.exports = merge(commons, env !== 'development' ? production : dev);