-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
webpack.config.js
79 lines (71 loc) · 1.69 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
79
// Dependencies
const path = require('path');
const _ = require('lodash');
// Plugins
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
// Common Settings
const common = {
entry: './src/snap-slider.js',
mode: 'none',
optimization: {
nodeEnv: 'development',
},
devtool: false,
devServer: {
contentBase: './docs',
watchContentBase: true,
},
stats: {
modules: false,
},
module: {
rules: [
{
test: /\.m?js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
plugins: [
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-transform-spread',
],
},
},
},
],
},
output: {
filename: 'snap-slider.js',
path: path.resolve(__dirname, '.'),
library: 'SnapSlider',
libraryTarget: 'umd',
libraryExport: 'default',
},
};
// Bundle Analyzer
const analyzer = new BundleAnalyzerPlugin({
analyzerMode: 'static',
openAnalyzer: process.env.TEST !== 'true',
});
// Build Settings
const full = _.cloneDeep(common);
const fullMin = _.cloneDeep(full);
fullMin.output.filename = 'snap-slider.min.js';
fullMin.mode = 'production';
fullMin.devtool = 'source-map';
const lite = _.cloneDeep(common);
lite.optimization.nodeEnv = 'production';
lite.output.filename = 'snap-slider.lite.js';
const liteMin = _.cloneDeep(lite);
liteMin.output.filename = 'snap-slider.lite.min.js';
liteMin.mode = 'production';
liteMin.devtool = 'source-map';
liteMin.plugins = [analyzer];
module.exports = [
full,
fullMin,
lite,
liteMin,
];