-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.config.js
57 lines (51 loc) · 1.38 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
/* global __dirname, require, module*/
const path = require('path');
const env = require('yargs').argv.env;
module.exports = function (libraryRoot, outputSuffix, target) {
const pkg = require(libraryRoot + '/package.json');
let libraryName = pkg.name;
let outputFile, mode;
console.log(env);
if (env === 'build') {
mode = 'production';
outputFile = libraryName + outputSuffix + '.min.js';
} else {
mode = 'development';
outputFile = libraryName + outputSuffix + '.js';
}
return {
target: target,
mode: mode,
entry: [libraryRoot + '/index.js'],
devtool: 'source-map',
output: {
path: libraryRoot + '/lib',
filename: outputFile,
library: libraryName,
libraryTarget: 'umd',
umdNamedDefine: true,
globalObject: "typeof self !== 'undefined' ? self : this"
},
module: {
rules: [
{
test: /(\.js)$/,
loader: 'babel-loader',
exclude: /(node_modules|bower_components)/
},
{
test: /(\.js)$/,
loader: 'eslint-loader',
exclude: /node_modules/
}
]
},
optimization: {
usedExports: true
},
resolve: {
modules: [path.resolve(libraryRoot + '/node_modules'), path.resolve(__dirname + '/node_modules'), path.resolve(libraryRoot + '/src')],
extensions: ['.mjs', '.json', '.js']
}
};
};