-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathwebpack.config.js
More file actions
77 lines (70 loc) · 1.76 KB
/
Copy pathwebpack.config.js
File metadata and controls
77 lines (70 loc) · 1.76 KB
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
const path = require('path');
function babelRule() {
return {
test: /\.m?js$/,
use: {
loader: 'babel-loader',
options: {
presets: [['@babel/preset-env' ]],
plugins: ["@babel/plugin-transform-modules-commonjs", "@babel/plugin-proposal-class-properties"]
}
}
};
}
function commonConfig() {
return {
module: {
rules: [babelRule()]
}
}
}
var configs = [];
var browserConfig = commonConfig();
browserConfig.entry = path.join(__dirname, './source/ucumPkg.js');
browserConfig.target = 'web';
browserConfig.mode = 'development';
browserConfig.devtool = 'source-map';
browserConfig.output = {
path: path.join(__dirname, './browser-dist'),
filename: 'ucum-lhc.js',
library: {
name: 'ucumPkg',
type: 'umd'
},
globalObject: 'this'
};
configs.push(browserConfig);
var browserMinConfig = commonConfig();
browserMinConfig.entry = path.join(__dirname, './source/ucumPkg.js');
browserMinConfig.target = 'web';
browserMinConfig.mode = 'production';
browserMinConfig.devtool = 'source-map';
browserMinConfig.output = {
path: path.join(__dirname, './browser-dist'),
filename: 'ucum-lhc.min.js',
library: {
name: 'ucumPkg',
type: 'umd'
},
globalObject: 'this'
};
configs.push(browserMinConfig);
var progConfig = commonConfig();
progConfig.target = 'node';
progConfig.mode = 'development';
progConfig.entry = path.join(__dirname, './impexp/updateData.js');
progConfig.externals = [
function ({context, request}, callback) {
if(/ucumDefs\.json/.test(request)) {
return callback(null, 'commonjs ' + request);
}
callback();
}
];
progConfig.output = {
path: __dirname,
filename: './impexp/updateDataBuild.js',
library: 'ucum'
};
configs.push(progConfig);
module.exports = configs;