-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathwebpack.config.cdn.js
More file actions
44 lines (42 loc) · 1.16 KB
/
webpack.config.cdn.js
File metadata and controls
44 lines (42 loc) · 1.16 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
/* eslint @typescript-eslint/no-var-requires: 0 */
const config = require("./webpack.config.js");
const version = require("./package.json").version;
const majorVersion = parseInt(version.split(".")[0]);
if (isNaN(majorVersion)) {
throw new Error("Unable to parse version number in package.json");
}
/**
* Creates the dist that's published to 'https://js.bytescale.com/upload-widget-react/v*'.
*/
module.exports = {
...config,
entry: "./src/index.cdn.ts",
output: {
...config.output,
filename: `v${majorVersion}.js`,
libraryTarget: "umd"
},
optimization: {}, // Re-enable optimizations (i.e. minification) for CDN bundle. (See base config.)
// Important: causes all dependencies to be bundled into one JS file.
externals: {
"react": {
root: "React",
commonjs: "react",
commonjs2: "react",
amd: "react"
},
"react-dom": {
root: "ReactDOM",
commonjs: "react-dom",
commonjs2: "react-dom",
amd: "react-dom"
}
},
resolve: {
...config.resolve,
modules: [
// Default value (resolve relative 'node_modules' from current dir, and up the ancestors).
"node_modules"
]
}
};