-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathwebpack.config.cdn.js
35 lines (33 loc) · 1.23 KB
/
webpack.config.cdn.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
/* eslint @typescript-eslint/no-var-requires: 0 */
const config = require("./webpack.config.base.js");
const externals = require("./webpack.config.externals.js");
const version = require("./package.json").version;
const majorVersion = parseInt(version.split(".")[0]);
const path = require("path");
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/sdk/v*'.
*/
module.exports = {
...config,
entry: "./src/index.browser.ts",
output: {
path: path.resolve(__dirname, "dist"),
filename: `v${majorVersion}.js`,
libraryTarget: "umd",
library: "Bytescale" // Causes all exports of "index.ts" to appear as members of a global "Bytescale" object.
},
optimization: {}, // Re-enable optimizations (i.e. minification) for CDN bundle. (See base config.)
// Important: causes all dependencies to be bundled into one JS file (except "stream" and "buffer" which doesn't exist
// in the browser, so we still treat as external).
externals,
resolve: {
...config.resolve,
modules: [
// Default value (resolve relative 'node_modules' from current dir, and up the ancestors).
"node_modules"
]
}
};