-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathwebpack.parts.ts
48 lines (38 loc) · 1.24 KB
/
webpack.parts.ts
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
import { resolve } from "path";
import { Configuration } from "webpack";
import { merge } from "webpack-merge";
import { development } from "./webpack.development";
import { production } from "./webpack.production";
export const paths: { [index: string]: string } = {
entry: resolve(__dirname, "./dist/src/index.js"),
bundle: resolve(__dirname, "./dist/browser"),
};
export const outputs = (
base: Configuration,
environment: string,
mappings: { [index: string]: string },
overrides: Configuration,
): Configuration[] => {
const configurations: Configuration[] = [];
const library: string = "masa-sdk";
const windowLibrary: string = "MasaSDK";
let configuration: Configuration = development;
let ext = "js";
if (environment === "production") {
configuration = production;
ext = `min.${ext}`;
}
for (const [target, extension] of Object.entries(mappings)) {
const filename = `${library}.${extension}.${ext}`;
const compiled: Configuration = {
output: {
filename,
library: target === "window" ? windowLibrary : library,
libraryTarget: target,
path: paths.bundle,
},
};
configurations.push(merge(base, configuration, compiled, overrides));
}
return configurations;
};