-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathwebpack.config.js
More file actions
49 lines (46 loc) · 1.65 KB
/
webpack.config.js
File metadata and controls
49 lines (46 loc) · 1.65 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
const path = require('path');
var config = {
mode: 'development',
entry: './src/main.js',
output: {
hashFunction: "sha256",
filename: 'jsColorEngine.js',
path: path.resolve(__dirname, './package'),
libraryTarget: 'umd',
// Make the UMD wrapper safe in Node, web workers, and the main browser
// window. Webpack 5's default of 'self' breaks `require()` in Node
// because the very first thing the wrapper does is read `self`, which
// is undefined outside browser contexts. See GitHub issue #2.
globalObject: "typeof self !== 'undefined' ? self : this"
},
externals: {
fs: "commonjs fs",
path: "commonjs path",
utils: "commonjs utils",
},
externalsPresets: {
node: true,
},
}
module.exports = (env, argv) => {
if (argv.mode === 'development') {
config.devtool = 'source-map';
config.output.path = path.resolve(__dirname, './dev')
if (env && env.TARGET_WEB) {
config.output.libraryTarget = 'var';
config.output.library = 'jsColorEngine';
config.output.filename = 'jsColorEngineWeb.js';
config.output.path = path.resolve(__dirname, './browser-dev');
}
}
if (argv.mode === 'production') {
config.output.path = path.resolve(__dirname, './build')
if (env && env.TARGET_WEB) {
config.output.libraryTarget = 'var';
config.output.library = 'jsColorEngine';
config.output.filename = 'jsColorEngineWeb.js';
config.output.path = path.resolve(__dirname, './browser');
}
}
return config;
};