-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathwebpack.config.js
40 lines (34 loc) · 940 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
const path = require('path');
const UglifyWebpackPlugin = require('uglifyjs-webpack-plugin');
const libraryTargets = ['var', 'commonjs2', 'amd', 'umd'];
const createConfig = (env, argv) => libraryTargets.map((target) => {
const config = {
entry: './src/index.js',
devtool: 'source-map',
output: {
path: path.resolve(__dirname, 'dist'),
filename: `pitch-analyser.${target}.js`,
library: 'PitchAnalyser', // Because it's a class :shrug
libraryTarget: target,
libraryExport: 'default',
},
optimization: {
minimizer: [],
},
module: {
rules: [
{
test: /\.js$/,
use: 'babel-loader',
exclude: /(node_modules|bower_components)/,
},
],
},
};
if (argv.mode === 'development') {}
if (argv.mode === 'production') {
config.optimization.minimizer.push(new UglifyWebpackPlugin({ sourceMap: true }));
}
return config;
});
module.exports = (env, argv) => createConfig(env, argv);