@servicetitan/startup 26.0.2 → 26.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/utils/get-configuration.d.ts +9 -0
- package/dist/utils/get-configuration.d.ts.map +1 -1
- package/dist/utils/get-configuration.js +9 -17
- package/dist/utils/get-configuration.js.map +1 -1
- package/dist/webpack/configs/optimization-config.d.ts.map +1 -1
- package/dist/webpack/configs/optimization-config.js +75 -47
- package/dist/webpack/configs/optimization-config.js.map +1 -1
- package/dist/webpack/configs/output-config.js +1 -1
- package/dist/webpack/configs/output-config.js.map +1 -1
- package/dist/webpack/configs/plugins/mini-css-extract-plugin.d.ts.map +1 -1
- package/dist/webpack/configs/plugins/mini-css-extract-plugin.js +3 -5
- package/dist/webpack/configs/plugins/mini-css-extract-plugin.js.map +1 -1
- package/dist/webpack/configs/types.d.ts +2 -1
- package/dist/webpack/configs/types.d.ts.map +1 -1
- package/dist/webpack/create-webpack-config.d.ts.map +1 -1
- package/dist/webpack/create-webpack-config.js +9 -2
- package/dist/webpack/create-webpack-config.js.map +1 -1
- package/package.json +6 -5
- package/src/index.ts +1 -0
- package/src/utils/get-configuration.ts +18 -21
- package/src/webpack/__tests__/create-webpack-config.test.ts +47 -3
- package/src/webpack/configs/optimization-config.ts +89 -49
- package/src/webpack/configs/output-config.ts +1 -1
- package/src/webpack/configs/plugins/mini-css-extract-plugin.ts +4 -5
- package/src/webpack/configs/types.ts +2 -1
- package/src/webpack/create-webpack-config.ts +11 -3
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,sBAAsB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -16,4 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./webpack"), exports);
|
|
18
18
|
__exportStar(require("./jest"), exports);
|
|
19
|
+
__exportStar(require("./utils/get-packages"), exports);
|
|
19
20
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,yCAAuB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,yCAAuB;AACvB,uDAAqC"}
|
|
@@ -4,12 +4,20 @@ import { LinterOptions } from 'stylelint';
|
|
|
4
4
|
import { Config } from '@jest/types';
|
|
5
5
|
export declare const allowedWebpackDevServerOptions: readonly ["headers", "port", "proxy", "static"];
|
|
6
6
|
type ElementType<T> = T extends readonly (infer ElementType)[] ? ElementType : never;
|
|
7
|
+
export interface MinifyJSOptions {
|
|
8
|
+
compress?: boolean;
|
|
9
|
+
mangle?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface MinifyOptions {
|
|
12
|
+
js?: boolean | MinifyJSOptions;
|
|
13
|
+
}
|
|
7
14
|
export interface WebpackConfiguration extends Omit<Pick<WebpackDevServerConfiguration, ElementType<typeof allowedWebpackDevServerOptions>>, 'proxy'> {
|
|
8
15
|
'contentBase'?: boolean | string | string[] | number;
|
|
9
16
|
'custom-style-rules'?: boolean;
|
|
10
17
|
'expose-shared-dependencies'?: boolean;
|
|
11
18
|
'devServer'?: WebpackDevServerConfiguration;
|
|
12
19
|
'disable-style-check'?: boolean;
|
|
20
|
+
'minify'?: MinifyOptions;
|
|
13
21
|
'proxy'?: WebpackDevServerConfiguration['proxy'] | string;
|
|
14
22
|
}
|
|
15
23
|
export interface ESLintConfiguration extends ESLint.Options {
|
|
@@ -60,6 +68,7 @@ export declare function getConfigurationSafe(locationOrJson?: LocationOrJson): C
|
|
|
60
68
|
export declare function getESLintConfiguration(): ESLintConfiguration;
|
|
61
69
|
export declare function getJestConfiguration(): JestConfiguration & NodeConfiguration;
|
|
62
70
|
export declare function getStylelintConfiguration(): StylelintConfiguration;
|
|
71
|
+
export declare function getWebpackConfiguration(locationOrJson?: LocationOrJson): WebpackConfiguration;
|
|
63
72
|
export declare function isBundle(locationOrJson?: LocationOrJson): boolean;
|
|
64
73
|
export declare function isCustomStyleRules(): boolean;
|
|
65
74
|
export declare function isExposeSharedDependencies(): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-configuration.d.ts","sourceRoot":"","sources":["../../src/utils/get-configuration.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,IAAI,6BAA6B,EAAE,MAAM,oBAAoB,CAAC;AACpF,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGrC,eAAO,MAAM,8BAA8B,iDAAkD,CAAC;AAE9F,KAAK,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,CAAC,MAAM,WAAW,CAAC,EAAE,GAAG,WAAW,GAAG,KAAK,CAAC;AAErF,MAAM,WAAW,oBACb,SAAQ,IAAI,CACR,IAAI,CAAC,6BAA6B,EAAE,WAAW,CAAC,OAAO,8BAA8B,CAAC,CAAC,EACvF,OAAO,CACV;IACD,aAAa,CAAC,EAAE,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AAO,CAAC;CACvB;AAED,KAAK,aAAa,GAAG;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE;QAAE,MAAM,EAAE,mBAAmB,CAAC;QAAC,SAAS,EAAE,sBAAsB,CAAA;KAAE,CAAC;IAC5E,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B,eAAe,CAAC,EAAE,OAAO,GAAG,mBAAmB,CAAC;IAChD,SAAS,CAAC,EAAE,KAAK,GAAG,oBAAoB,CAAC;CAC5C,GAAG;KACC,GAAG,IAAI,WAAW,GAAG,iBAAiB;CAC1C,GAAG,iBAAiB,CAAC;AAEtB,KAAK,cAAc,GAAG,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAEnD,wBAAgB,gBAAgB,CAAC,cAAc,GAAE,cAAqB,GAAG,aAAa,CAMrF;AAED,wBAAgB,oBAAoB,CAAC,cAAc,GAAE,cAAqB,GAAG,aAAa,CAMzF;AAED,wBAAgB,sBAAsB,wBAErC;AAED,wBAAgB,oBAAoB,0CAEnC;AAED,wBAAgB,yBAAyB,2BAExC;AAED,wBAAgB,uBAAuB,CAAC,cAAc,CAAC,EAAE,cAAc,wBAGtE;AAED,wBAAgB,QAAQ,CAAC,cAAc,CAAC,EAAE,cAAc,WAEvD;AAED,wBAAgB,kBAAkB,YAEjC;AAED,wBAAgB,0BAA0B,YAEzC;AAED,wBAAgB,QAAQ,CAAC,cAAc,CAAC,EAAE,cAAc,WAEvD;AAED,wBAAgB,YAAY,YAG3B;AAED,wBAAgB,oBAAoB,YAEnC;AAED,wBAAgB,cAAc,YAG7B"}
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.isWebComponent = exports.isStyleCheckDisabled = exports.isLegacyRoot = exports.isLegacy = exports.isExposeSharedDependencies = exports.isCustomStyleRules = exports.isBundle = exports.getStylelintConfiguration = exports.getJestConfiguration = exports.getESLintConfiguration = exports.getConfigurationSafe = exports.getConfiguration = exports.CommandName = exports.allowedWebpackDevServerOptions = void 0;
|
|
6
|
+
exports.isWebComponent = exports.isStyleCheckDisabled = exports.isLegacyRoot = exports.isLegacy = exports.isExposeSharedDependencies = exports.isCustomStyleRules = exports.isBundle = exports.getWebpackConfiguration = exports.getStylelintConfiguration = exports.getJestConfiguration = exports.getESLintConfiguration = exports.getConfigurationSafe = exports.getConfiguration = exports.CommandName = exports.allowedWebpackDevServerOptions = void 0;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const read_json_1 = require("./read-json");
|
|
9
9
|
exports.allowedWebpackDevServerOptions = ['headers', 'port', 'proxy', 'static'];
|
|
@@ -56,24 +56,21 @@ function getStylelintConfiguration() {
|
|
|
56
56
|
return (_b = (_a = getConfiguration().lint) === null || _a === void 0 ? void 0 : _a.stylelint) !== null && _b !== void 0 ? _b : {};
|
|
57
57
|
}
|
|
58
58
|
exports.getStylelintConfiguration = getStylelintConfiguration;
|
|
59
|
+
function getWebpackConfiguration(locationOrJson) {
|
|
60
|
+
const { webpack } = getConfiguration(locationOrJson);
|
|
61
|
+
return typeof webpack === 'object' ? webpack : {};
|
|
62
|
+
}
|
|
63
|
+
exports.getWebpackConfiguration = getWebpackConfiguration;
|
|
59
64
|
function isBundle(locationOrJson) {
|
|
60
65
|
return getConfiguration(locationOrJson).webpack !== false;
|
|
61
66
|
}
|
|
62
67
|
exports.isBundle = isBundle;
|
|
63
68
|
function isCustomStyleRules() {
|
|
64
|
-
|
|
65
|
-
if (typeof configuration.webpack !== 'object') {
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
return configuration.webpack['custom-style-rules'] === true;
|
|
69
|
+
return getWebpackConfiguration()['custom-style-rules'] === true;
|
|
69
70
|
}
|
|
70
71
|
exports.isCustomStyleRules = isCustomStyleRules;
|
|
71
72
|
function isExposeSharedDependencies() {
|
|
72
|
-
|
|
73
|
-
if (typeof configuration.webpack !== 'object') {
|
|
74
|
-
return false;
|
|
75
|
-
}
|
|
76
|
-
return configuration.webpack['expose-shared-dependencies'] === true;
|
|
73
|
+
return getWebpackConfiguration()['expose-shared-dependencies'] === true;
|
|
77
74
|
}
|
|
78
75
|
exports.isExposeSharedDependencies = isExposeSharedDependencies;
|
|
79
76
|
function isLegacy(locationOrJson) {
|
|
@@ -86,12 +83,7 @@ function isLegacyRoot() {
|
|
|
86
83
|
}
|
|
87
84
|
exports.isLegacyRoot = isLegacyRoot;
|
|
88
85
|
function isStyleCheckDisabled() {
|
|
89
|
-
|
|
90
|
-
const configuration = getConfiguration();
|
|
91
|
-
if (typeof configuration.webpack !== 'object') {
|
|
92
|
-
return false;
|
|
93
|
-
}
|
|
94
|
-
return ((_a = configuration.webpack) === null || _a === void 0 ? void 0 : _a['disable-style-check']) === true;
|
|
86
|
+
return getWebpackConfiguration()['disable-style-check'] === true;
|
|
95
87
|
}
|
|
96
88
|
exports.isStyleCheckDisabled = isStyleCheckDisabled;
|
|
97
89
|
function isWebComponent() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-configuration.js","sourceRoot":"","sources":["../../src/utils/get-configuration.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AAMxB,2CAAqD;AAExC,QAAA,8BAA8B,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"get-configuration.js","sourceRoot":"","sources":["../../src/utils/get-configuration.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AAMxB,2CAAqD;AAExC,QAAA,8BAA8B,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAU,CAAC;AA2C9F,yDAAyD;AACzD,IAAY,WAeX;AAfD,WAAY,WAAW;IACnB,8BAAiB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Q,CAAC;AACzD,CAAC;AAHD,wCAGC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"optimization-config.d.ts","sourceRoot":"","sources":["../../../src/webpack/configs/optimization-config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"optimization-config.d.ts","sourceRoot":"","sources":["../../../src/webpack/configs/optimization-config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAI7C,KAAK,MAAM,GAAG,IAAI,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC;AAElD,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,SAAS,GAAG,MAAM,CAmBzE"}
|
|
@@ -1,63 +1,91 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.optimizationConfig = void 0;
|
|
7
|
+
const terser_webpack_plugin_1 = __importDefault(require("terser-webpack-plugin"));
|
|
4
8
|
function optimizationConfig(context, _) {
|
|
5
|
-
const {
|
|
9
|
+
const { isProduction } = context;
|
|
6
10
|
const optimization = {
|
|
7
|
-
chunkIds: '
|
|
11
|
+
chunkIds: isProduction ? 'deterministic' : 'named',
|
|
8
12
|
moduleIds: 'size',
|
|
9
13
|
mangleExports: 'size',
|
|
10
14
|
splitChunks: { cacheGroups: {} },
|
|
11
15
|
};
|
|
12
|
-
if (isExposeSharedDependencies) {
|
|
13
|
-
Object.assign(optimization.splitChunks.cacheGroups, {
|
|
14
|
-
'design-system': {
|
|
15
|
-
test: /[\\/]node_modules[\\/]@servicetitan[\\/](tokens|anvil-fonts|design-system)[\\/].*\.css$/,
|
|
16
|
-
name: 'design-system',
|
|
17
|
-
chunks: 'all',
|
|
18
|
-
enforce: true,
|
|
19
|
-
},
|
|
20
|
-
'anvil2': {
|
|
21
|
-
test: /@servicetitan\/anvil2\/.*\.css$/,
|
|
22
|
-
name: 'anvil2',
|
|
23
|
-
chunks: 'all',
|
|
24
|
-
enforce: true,
|
|
25
|
-
},
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
if (isWebComponent) {
|
|
29
|
-
Object.assign(optimization.splitChunks.cacheGroups, {
|
|
30
|
-
styles: {
|
|
31
|
-
name: 'main',
|
|
32
|
-
type: 'css/mini-extract',
|
|
33
|
-
chunks: 'all',
|
|
34
|
-
enforce: true,
|
|
35
|
-
},
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
16
|
if (isProduction) {
|
|
39
17
|
optimization.runtimeChunk = 'single';
|
|
40
|
-
if (isWebComponent) {
|
|
41
|
-
Object.assign(optimization.splitChunks.cacheGroups, {
|
|
42
|
-
common: {
|
|
43
|
-
name: 'common',
|
|
44
|
-
test: /[\\/]node_modules[\\/](axios|classnames|formstate|mobx|mobx-react|mobx-utils|react|react-dom|react-router|react-router-dom)[\\/]/,
|
|
45
|
-
chunks: 'all',
|
|
46
|
-
},
|
|
47
|
-
kendo: {
|
|
48
|
-
name: 'kendo',
|
|
49
|
-
test: /[\\/]node_modules[\\/](@progress|@telerik)[\\/]/,
|
|
50
|
-
chunks: 'all',
|
|
51
|
-
},
|
|
52
|
-
servicetitan: {
|
|
53
|
-
name: 'servicetitan',
|
|
54
|
-
test: /[\\/]node_modules[\\/]@servicetitan[\\/]/,
|
|
55
|
-
chunks: 'all',
|
|
56
|
-
},
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
18
|
}
|
|
19
|
+
[minimizeConfig, sharedDependenciesConfig, webComponentConfig].forEach(handler => handler(optimization, context));
|
|
60
20
|
return { optimization };
|
|
61
21
|
}
|
|
62
22
|
exports.optimizationConfig = optimizationConfig;
|
|
23
|
+
function minimizeConfig(optimization, context) {
|
|
24
|
+
var _a, _b;
|
|
25
|
+
const { isProduction } = context;
|
|
26
|
+
if (!isProduction) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const minify = (_b = (_a = context.minify) === null || _a === void 0 ? void 0 : _a.js) !== null && _b !== void 0 ? _b : true;
|
|
30
|
+
optimization.minimize = !!minify;
|
|
31
|
+
if (!optimization.minimize) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const terserOptions = Object.assign({ compress: false, mangle: false }, (typeof minify === 'object' ? minify : {}));
|
|
35
|
+
optimization.minimizer = [new terser_webpack_plugin_1.default({ terserOptions })];
|
|
36
|
+
}
|
|
37
|
+
function sharedDependenciesConfig(optimization, context) {
|
|
38
|
+
const { isExposeSharedDependencies } = context;
|
|
39
|
+
if (!isExposeSharedDependencies) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
Object.assign(optimization.splitChunks.cacheGroups, {
|
|
43
|
+
'design-system': {
|
|
44
|
+
test: /[\\/]node_modules[\\/]@servicetitan[\\/](tokens|anvil-fonts|design-system)[\\/].*\.css$/,
|
|
45
|
+
name: 'design-system',
|
|
46
|
+
chunks: 'all',
|
|
47
|
+
enforce: true,
|
|
48
|
+
},
|
|
49
|
+
'anvil2': {
|
|
50
|
+
test: /@servicetitan\/anvil2\/.*\.css$/,
|
|
51
|
+
name: 'anvil2',
|
|
52
|
+
chunks: 'all',
|
|
53
|
+
enforce: true,
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
function webComponentConfig(optimization, context) {
|
|
58
|
+
const { isWebComponent, isProduction } = context;
|
|
59
|
+
if (!isWebComponent) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
Object.assign(optimization.splitChunks.cacheGroups, {
|
|
63
|
+
styles: {
|
|
64
|
+
name: 'main',
|
|
65
|
+
type: 'css/mini-extract',
|
|
66
|
+
chunks: 'all',
|
|
67
|
+
enforce: true,
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
if (!isProduction) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
Object.assign(optimization.splitChunks.cacheGroups, {
|
|
74
|
+
common: {
|
|
75
|
+
name: 'common',
|
|
76
|
+
test: /[\\/]node_modules[\\/](axios|classnames|formstate|mobx|mobx-react|mobx-utils|react|react-dom|react-router|react-router-dom)[\\/]/,
|
|
77
|
+
chunks: 'all',
|
|
78
|
+
},
|
|
79
|
+
kendo: {
|
|
80
|
+
name: 'kendo',
|
|
81
|
+
test: /[\\/]node_modules[\\/](@progress|@telerik)[\\/]/,
|
|
82
|
+
chunks: 'all',
|
|
83
|
+
},
|
|
84
|
+
servicetitan: {
|
|
85
|
+
name: 'servicetitan',
|
|
86
|
+
test: /[\\/]node_modules[\\/]@servicetitan[\\/]/,
|
|
87
|
+
chunks: 'all',
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
}
|
|
63
91
|
//# sourceMappingURL=optimization-config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"optimization-config.js","sourceRoot":"","sources":["../../../src/webpack/configs/optimization-config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"optimization-config.js","sourceRoot":"","sources":["../../../src/webpack/configs/optimization-config.ts"],"names":[],"mappings":";;;;;;AAAA,kFAAiD;AAQjD,SAAgB,kBAAkB,CAAC,OAAgB,EAAE,CAAY;IAC7D,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;IAEjC,MAAM,YAAY,GAA0B;QACxC,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,OAAO;QAClD,SAAS,EAAE,MAAM;QACjB,aAAa,EAAE,MAAM;QACrB,WAAW,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE;KACnC,CAAC;IAEF,IAAI,YAAY,EAAE,CAAC;QACf,YAAY,CAAC,YAAY,GAAG,QAAQ,CAAC;IACzC,CAAC;IAED,C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C,IAAI,EAAE,QAAQ;YACd,MAAM,EAAE,KAAK;YACb,OAAO,EAAE,IAAI;SAChB;KACJ,CAAC,CAAC;AACP,CAAC;AAED,SAAS,kBAAkB,CAAC,YAAmC,EAAE,OAAgB;IAC7E,MAAM,EAAE,cAAc,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;IACjD,IAAI,CAAC,cAAc,EAAE,CAAC;QAClB,OAAO;IACX,CAAC;IAED,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,WAAW,CAAC,WAAW,EAAE;QAChD,MAAM,EAAE;YACJ,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,kBAAkB;YACxB,MAAM,EAAE,KAAK;YACb,OAAO,EAAE,IAAI;SAChB;KACJ,CAAC,CAAC;IAEH,IAAI,CAAC,YAAY,EAAE,CAAC;QAChB,OAAO;IACX,CAAC;IAED,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,WAAW,CAAC,WAAW,EAAE;QAChD,MAAM,EAAE;YACJ,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,kIAAkI;YACxI,MAAM,EAAE,KAAK;SAChB;QACD,KAAK,EAAE;YACH,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,iDAAiD;YACvD,MAAM,EAAE,KAAK;SAChB;QACD,YAAY,EAAE;YACV,IAAI,EAAE,cAAc;YACpB,IAAI,EAAE,0CAA0C;YAChD,MAAM,EAAE,KAAK;SAChB;KACJ,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -15,7 +15,7 @@ function outputConfig(context, _) {
|
|
|
15
15
|
};
|
|
16
16
|
if (isProduction) {
|
|
17
17
|
const cdnPath = process.env.CLIENT_CDN_PATH;
|
|
18
|
-
Object.assign(output, Object.assign({ filename: '[name].[contenthash
|
|
18
|
+
Object.assign(output, Object.assign({ filename: '[name].[contenthash].bundle.js', clean: true }, (cdnPath ? { publicPath: cdnPath } : {})));
|
|
19
19
|
}
|
|
20
20
|
return { output };
|
|
21
21
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output-config.js","sourceRoot":"","sources":["../../../src/webpack/configs/output-config.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AAOxB,SAAgB,YAAY,CAAC,OAAgB,EAAE,CAAY;IACvD,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC;IAErE,MAAM,MAAM,GAAW;QACnB,QAAQ,EAAE,kBAAkB;QAC5B,IAAI,EAAE,cAAc;YAChB,CAAC,CAAC,cAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,GAAG,WAAW,WAAW,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;YAC/E,CAAC,CAAC,cAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,GAAG,WAAW,SAAS,CAAC;KAC1D,CAAC;IAEF,IAAI,YAAY,EAAE,CAAC;QACf,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC;QAC5C,MAAM,CAAC,MAAM,CAAC,MAAM,kBAChB,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"output-config.js","sourceRoot":"","sources":["../../../src/webpack/configs/output-config.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AAOxB,SAAgB,YAAY,CAAC,OAAgB,EAAE,CAAY;IACvD,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC;IAErE,MAAM,MAAM,GAAW;QACnB,QAAQ,EAAE,kBAAkB;QAC5B,IAAI,EAAE,cAAc;YAChB,CAAC,CAAC,cAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,GAAG,WAAW,WAAW,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;YAC/E,CAAC,CAAC,cAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,GAAG,WAAW,SAAS,CAAC;KAC1D,CAAC;IAEF,IAAI,YAAY,EAAE,CAAC;QACf,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC;QAC5C,MAAM,CAAC,MAAM,CAAC,MAAM,kBAChB,QAAQ,EAAE,gCAAgC,EAC1C,KAAK,EAAE,IAAI,IACR,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAC7C,CAAC;IACP,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,CAAC;AACtB,CAAC;AApBD,oCAoBC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mini-css-extract-plugin.d.ts","sourceRoot":"","sources":["../../../../src/webpack/configs/plugins/mini-css-extract-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE9C,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"mini-css-extract-plugin.d.ts","sourceRoot":"","sources":["../../../../src/webpack/configs/plugins/mini-css-extract-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE9C,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,oCAc1E"}
|
|
@@ -10,13 +10,11 @@ function miniCssExtractPlugin(context, overrides) {
|
|
|
10
10
|
const { isCustomStyleRules, isExposeSharedDependencies, isProduction, isWebComponent } = context;
|
|
11
11
|
if (isProduction) {
|
|
12
12
|
if (!isCustomStyleRules) {
|
|
13
|
-
return new mini_css_extract_plugin_1.default(Object.assign({ filename: '[name].[contenthash
|
|
13
|
+
return new mini_css_extract_plugin_1.default(Object.assign({ filename: '[name].[contenthash].bundle.css' }, (_a = overrides.plugins) === null || _a === void 0 ? void 0 : _a.MiniCssExtractPlugin));
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
-
else {
|
|
17
|
-
|
|
18
|
-
return new mini_css_extract_plugin_1.default({ filename: '[name].bundle.css' });
|
|
19
|
-
}
|
|
16
|
+
else if (isWebComponent || (isExposeSharedDependencies && !isCustomStyleRules)) {
|
|
17
|
+
return new mini_css_extract_plugin_1.default({ filename: '[name].bundle.css' });
|
|
20
18
|
}
|
|
21
19
|
}
|
|
22
20
|
exports.miniCssExtractPlugin = miniCssExtractPlugin;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mini-css-extract-plugin.js","sourceRoot":"","sources":["../../../../src/webpack/configs/plugins/mini-css-extract-plugin.ts"],"names":[],"mappings":";;;;;;AAAA,sFAA2D;AAG3D,SAAgB,oBAAoB,CAAC,OAAgB,EAAE,SAAoB;;IACvE,MAAM,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,YAAY,EAAE,cAAc,EAAE,GAClF,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"mini-css-extract-plugin.js","sourceRoot":"","sources":["../../../../src/webpack/configs/plugins/mini-css-extract-plugin.ts"],"names":[],"mappings":";;;;;;AAAA,sFAA2D;AAG3D,SAAgB,oBAAoB,CAAC,OAAgB,EAAE,SAAoB;;IACvE,MAAM,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,YAAY,EAAE,cAAc,EAAE,GAClF,OAAO,CAAC;IAEZ,IAAI,YAAY,EAAE,CAAC;QACf,IAAI,CAAC,kBAAkB,EAAE,CAAC;YACtB,OAAO,IAAI,iCAAoB,iBAC3B,QAAQ,EAAE,iCAAiC,IACxC,MAAC,SAAS,CAAC,OAAe,0CAAE,oBAAoB,EACrD,CAAC;QACP,CAAC;IACL,CAAC;SAAM,IAAI,cAAc,IAAI,CAAC,0BAA0B,IAAI,CAAC,kBAAkB,CAAC,EAAE,CAAC;QAC/E,OAAO,IAAI,iCAAoB,CAAC,EAAE,QAAQ,EAAE,mBAAmB,EAAE,CAAC,CAAC;IACvE,CAAC;AACL,CAAC;AAdD,oDAcC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getPackageData, loadSharedDependencies } from '../../utils';
|
|
1
|
+
import { getPackageData, loadSharedDependencies, MinifyOptions } from '../../utils';
|
|
2
2
|
import { Options } from '../types';
|
|
3
3
|
export { Overrides } from '../types';
|
|
4
4
|
export interface Context extends Options {
|
|
@@ -11,6 +11,7 @@ export interface Context extends Options {
|
|
|
11
11
|
isLegacyRoot: boolean;
|
|
12
12
|
isProduction: boolean;
|
|
13
13
|
isWebComponent: boolean;
|
|
14
|
+
minify?: MinifyOptions;
|
|
14
15
|
packageData: ReturnType<typeof getPackageData>;
|
|
15
16
|
sharedDependencies: ReturnType<typeof loadSharedDependencies>;
|
|
16
17
|
source: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/webpack/configs/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/webpack/configs/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACpF,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,MAAM,WAAW,OAAQ,SAAQ,OAAO;IACpC,YAAY,EAAE,OAAO,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,oBAAoB,EAAE,OAAO,CAAC;IAC9B,kBAAkB,EAAE,OAAO,CAAC;IAC5B,0BAA0B,EAAE,OAAO,CAAC;IACpC,YAAY,EAAE,OAAO,CAAC;IACtB,YAAY,EAAE,OAAO,CAAC;IACtB,cAAc,EAAE,OAAO,CAAC;IACxB,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,WAAW,EAAE,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;IAC/C,kBAAkB,EAAE,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAC;IAC9D,MAAM,EAAE,MAAM,CAAC;CAClB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-webpack-config.d.ts","sourceRoot":"","sources":["../../src/webpack/create-webpack-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"create-webpack-config.d.ts","sourceRoot":"","sources":["../../src/webpack/create-webpack-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AA+BxC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAG7C,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,GAAE,OAAY,GAAG,aAAa,CAwD9F"}
|
|
@@ -11,13 +11,14 @@ function createWebpackConfig(overrides, options = {}) {
|
|
|
11
11
|
var _a, _b, _c;
|
|
12
12
|
const { configuration = {} } = overrides;
|
|
13
13
|
const { source, destination } = (0, utils_2.getFolders)();
|
|
14
|
+
const { minify } = (0, utils_2.getWebpackConfiguration)();
|
|
14
15
|
const packageData = (0, utils_2.getPackageData)();
|
|
15
16
|
const sharedDependencies = (0, utils_2.loadSharedDependencies)(packageData.dependencies, packageData.sharedDependencies);
|
|
16
|
-
const context = Object.assign(Object.assign({ codeCoverage: (_a = options.codeCoverage) !== null && _a !== void 0 ? _a : !!yargs_1.argv['code-coverage'], destination, esbuild: (_b = options.esbuild) !== null && _b !== void 0 ? _b : !!yargs_1.argv.esbuild, experimentalBundlers: (_c = options.experimentalBundlers) !== null && _c !== void 0 ? _c : !!yargs_1.argv['experimental-bundlers'], isCustomStyleRules: (0, utils_2.isCustomStyleRules)(), isExposeSharedDependencies: (0, utils_2.isExposeSharedDependencies)(), isLegacyRoot: (0, utils_2.isLegacyRoot)(), isProduction: configuration.mode === 'production', isWebComponent: (0, utils_2.isWebComponent)(), name: '' }, options), { packageData,
|
|
17
|
+
const context = Object.assign(Object.assign({ codeCoverage: (_a = options.codeCoverage) !== null && _a !== void 0 ? _a : !!yargs_1.argv['code-coverage'], destination, esbuild: (_b = options.esbuild) !== null && _b !== void 0 ? _b : !!yargs_1.argv.esbuild, experimentalBundlers: (_c = options.experimentalBundlers) !== null && _c !== void 0 ? _c : !!yargs_1.argv['experimental-bundlers'], isCustomStyleRules: (0, utils_2.isCustomStyleRules)(), isExposeSharedDependencies: (0, utils_2.isExposeSharedDependencies)(), isLegacyRoot: (0, utils_2.isLegacyRoot)(), isProduction: configuration.mode === 'production', isWebComponent: (0, utils_2.isWebComponent)(), minify, name: '' }, options), { packageData,
|
|
17
18
|
sharedDependencies,
|
|
18
19
|
source });
|
|
19
20
|
if (context.isWebComponent && isCalledFromCustomWebpackConfigFile()) {
|
|
20
|
-
throw new Error(
|
|
21
|
+
throw new Error(WEB_COMPONENT_CONFIG_ERROR);
|
|
21
22
|
}
|
|
22
23
|
const result = (0, webpack_merge_1.merge)([
|
|
23
24
|
configs_1.cacheConfig,
|
|
@@ -63,4 +64,10 @@ function stringify(configuration) {
|
|
|
63
64
|
}
|
|
64
65
|
return JSON.stringify(configuration, replacer, 2);
|
|
65
66
|
}
|
|
67
|
+
const WEB_COMPONENT_CONFIG_ERROR = `
|
|
68
|
+
You cannot call createWebpackConfig in a custom webpack config file in a web component (MFE) project.
|
|
69
|
+
Export webpack configuration itself as a default export from the config file instead.
|
|
70
|
+
`
|
|
71
|
+
.replace(/\n\s*/g, ' ')
|
|
72
|
+
.trim();
|
|
66
73
|
//# sourceMappingURL=create-webpack-config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-webpack-config.js","sourceRoot":"","sources":["../../src/webpack/create-webpack-config.ts"],"names":[],"mappings":";;;AACA,iDAAsC;AACtC,iCAAwC;AAExC,wCAAmF;AACnF,
|
|
1
|
+
{"version":3,"file":"create-webpack-config.js","sourceRoot":"","sources":["../../src/webpack/create-webpack-config.ts"],"names":[],"mappings":";;;AACA,iDAAsC;AACtC,iCAAwC;AAExC,wCAAmF;AACnF,oCAUkB;AAClB,uCAcmB;AAEnB,mCAAwC;AAExC,SAAgB,mBAAmB,CAAC,SAAoB,EAAE,UAAmB,EAAE;;IAC3E,MAAM,EAAE,aAAa,GAAG,EAAE,EAAE,GAAG,SAAS,CAAC;IAEzC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,IAAA,kBAAU,GAAE,CAAC;IAC7C,MAAM,EAAE,MAAM,EAAE,GAAG,IAAA,+BAAuB,GAAE,CAAC;IAC7C,MAAM,WAAW,GAAG,IAAA,sBAAc,GAAE,CAAC;IACrC,MAAM,kBAAkB,GAAG,IAAA,8BAAsB,EAC7C,WAAW,CAAC,YAAY,EACxB,WAAW,CAAC,kBAAkB,CACjC,CAAC;IAEF,MAAM,OAAO,iCACT,YAAY,EAAE,MAAA,OAAO,CAAC,YAAY,mCAAI,CAAC,CAAE,YAAkB,CAAC,eAAe,CAAC,EAC5E,WAAW,EACX,OAAO,EAAE,MAAA,OAAO,CAAC,OAAO,mCAAI,CAAC,CAAE,YAAkB,CAAC,OAAO,EACzD,oBAAoB,EAChB,MAAA,OAAO,CAAC,oBAAoB,mCAAI,CAAC,CAAE,YAAkB,CAAC,uBAAuB,CAAC,EAClF,kBAAkB,EAAE,IAAA,0BAAkB,GAAE,EACxC,0BAA0B,EAAE,IAAA,kCAA0B,GAAE,EACxD,YAAY,EAAE,IAAA,oBAAY,GAAE,EAC5B,Y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AAE,GAAG,CAAC;QAC3C,CAAC;QACD,IAAI,KAAK,YAAY,MAAM,EAAE,CAAC;YAC1B,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;QACzB,CAAC;QACD,IAAI,GAAG,KAAK,SAAS,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YAC5C,OAAO,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;;gBACtB,MAAM,IAAI,GAAG,MAAA,MAAA,MAAM,CAAC,WAAW,0CAAE,IAAI,mCAAI,MAAM,CAAC,IAAI,CAAC;gBACrD,OAAO,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;YAC9C,CAAC,CAAC,CAAC;QACP,CAAC;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;IACD,OAAO,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;AACtD,CAAC;AAED,MAAM,0BAA0B,GAAG;;;CAGlC;KACI,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC;KACtB,IAAI,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@servicetitan/startup",
|
|
3
|
-
"version": "26.0
|
|
3
|
+
"version": "26.2.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"homepage": "https://docs.st.dev/docs/frontend/startup",
|
|
6
6
|
"repository": {
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"@babel/preset-env": "~7.25.3",
|
|
37
37
|
"@jest/core": "~29.7.0",
|
|
38
38
|
"@jest/types": "~29.6.3",
|
|
39
|
-
"@servicetitan/eslint-config": "26.0
|
|
40
|
-
"@servicetitan/stylelint-config": "26.0
|
|
39
|
+
"@servicetitan/eslint-config": "26.2.0",
|
|
40
|
+
"@servicetitan/stylelint-config": "26.2.0",
|
|
41
41
|
"@svgr/webpack": "^8.1.0",
|
|
42
42
|
"@swc/core": "1.6.13",
|
|
43
43
|
"@types/debug": "^4.1.12",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"moment-locales-webpack-plugin": "~1.2.0",
|
|
70
70
|
"multimatch": "~5.0.0",
|
|
71
71
|
"portfinder": "~1.0.32",
|
|
72
|
-
"postcss": "~8.4.
|
|
72
|
+
"postcss": "~8.4.41",
|
|
73
73
|
"prettier": "~2.7.1",
|
|
74
74
|
"sass": "~1.77.8",
|
|
75
75
|
"sass-loader": "~16.0.0",
|
|
@@ -78,6 +78,7 @@
|
|
|
78
78
|
"style-loader": "~4.0.0",
|
|
79
79
|
"stylelint": "~14.16.1",
|
|
80
80
|
"swc-loader": "0.2.6",
|
|
81
|
+
"terser-webpack-plugin": "^5.3.10",
|
|
81
82
|
"ts-jest": "~29.2.4",
|
|
82
83
|
"ts-loader": "~9.5.1",
|
|
83
84
|
"ts-node": "~10.9.2",
|
|
@@ -104,5 +105,5 @@
|
|
|
104
105
|
"cli": {
|
|
105
106
|
"webpack": false
|
|
106
107
|
},
|
|
107
|
-
"gitHead": "
|
|
108
|
+
"gitHead": "db962a72024497a2c475d3bbf9aab5f9c7aae223"
|
|
108
109
|
}
|
package/src/index.ts
CHANGED
|
@@ -10,6 +10,15 @@ export const allowedWebpackDevServerOptions = ['headers', 'port', 'proxy', 'stat
|
|
|
10
10
|
|
|
11
11
|
type ElementType<T> = T extends readonly (infer ElementType)[] ? ElementType : never;
|
|
12
12
|
|
|
13
|
+
export interface MinifyJSOptions {
|
|
14
|
+
compress?: boolean;
|
|
15
|
+
mangle?: boolean;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface MinifyOptions {
|
|
19
|
+
js?: boolean | MinifyJSOptions;
|
|
20
|
+
}
|
|
21
|
+
|
|
13
22
|
export interface WebpackConfiguration
|
|
14
23
|
extends Omit<
|
|
15
24
|
Pick<WebpackDevServerConfiguration, ElementType<typeof allowedWebpackDevServerOptions>>,
|
|
@@ -20,6 +29,7 @@ export interface WebpackConfiguration
|
|
|
20
29
|
'expose-shared-dependencies'?: boolean;
|
|
21
30
|
'devServer'?: WebpackDevServerConfiguration;
|
|
22
31
|
'disable-style-check'?: boolean;
|
|
32
|
+
'minify'?: MinifyOptions;
|
|
23
33
|
'proxy'?: WebpackDevServerConfiguration['proxy'] | string;
|
|
24
34
|
}
|
|
25
35
|
|
|
@@ -102,28 +112,21 @@ export function getStylelintConfiguration() {
|
|
|
102
112
|
return getConfiguration().lint?.stylelint ?? {};
|
|
103
113
|
}
|
|
104
114
|
|
|
115
|
+
export function getWebpackConfiguration(locationOrJson?: LocationOrJson) {
|
|
116
|
+
const { webpack } = getConfiguration(locationOrJson);
|
|
117
|
+
return typeof webpack === 'object' ? webpack : {};
|
|
118
|
+
}
|
|
119
|
+
|
|
105
120
|
export function isBundle(locationOrJson?: LocationOrJson) {
|
|
106
121
|
return getConfiguration(locationOrJson).webpack !== false;
|
|
107
122
|
}
|
|
108
123
|
|
|
109
124
|
export function isCustomStyleRules() {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
if (typeof configuration.webpack !== 'object') {
|
|
113
|
-
return false;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
return configuration.webpack['custom-style-rules'] === true;
|
|
125
|
+
return getWebpackConfiguration()['custom-style-rules'] === true;
|
|
117
126
|
}
|
|
118
127
|
|
|
119
128
|
export function isExposeSharedDependencies() {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
if (typeof configuration.webpack !== 'object') {
|
|
123
|
-
return false;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
return configuration.webpack['expose-shared-dependencies'] === true;
|
|
129
|
+
return getWebpackConfiguration()['expose-shared-dependencies'] === true;
|
|
127
130
|
}
|
|
128
131
|
|
|
129
132
|
export function isLegacy(locationOrJson?: LocationOrJson) {
|
|
@@ -136,13 +139,7 @@ export function isLegacyRoot() {
|
|
|
136
139
|
}
|
|
137
140
|
|
|
138
141
|
export function isStyleCheckDisabled() {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
if (typeof configuration.webpack !== 'object') {
|
|
142
|
-
return false;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
return configuration.webpack?.['disable-style-check'] === true;
|
|
142
|
+
return getWebpackConfiguration()['disable-style-check'] === true;
|
|
146
143
|
}
|
|
147
144
|
|
|
148
145
|
export function isWebComponent() {
|
|
@@ -5,6 +5,7 @@ import { fs, vol } from 'memfs';
|
|
|
5
5
|
import MomentLocalesPlugin from 'moment-locales-webpack-plugin';
|
|
6
6
|
import os from 'os';
|
|
7
7
|
import path from 'path';
|
|
8
|
+
const TerserPlugin = require('terser-webpack-plugin');
|
|
8
9
|
import { IgnorePlugin, ProvidePlugin } from 'webpack';
|
|
9
10
|
import WebpackDevServer from 'webpack-dev-server';
|
|
10
11
|
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
|
@@ -21,6 +22,7 @@ import {
|
|
|
21
22
|
getPackageDependencyVersion,
|
|
22
23
|
getPackages,
|
|
23
24
|
getTsConfig,
|
|
25
|
+
getWebpackConfiguration,
|
|
24
26
|
isCustomStyleRules,
|
|
25
27
|
isWebComponent,
|
|
26
28
|
loadSharedDependencies,
|
|
@@ -39,6 +41,7 @@ jest.mock('mini-css-extract-plugin', () =>
|
|
|
39
41
|
Object.assign(jest.fn(), { loader: 'MiniCssExtractPlugin.loader' })
|
|
40
42
|
);
|
|
41
43
|
jest.mock('moment-locales-webpack-plugin', () => jest.fn());
|
|
44
|
+
jest.mock('terser-webpack-plugin', () => jest.fn());
|
|
42
45
|
jest.mock('webpack', () => ({
|
|
43
46
|
...jest.requireActual('webpack'),
|
|
44
47
|
IgnorePlugin: jest.fn(),
|
|
@@ -57,6 +60,7 @@ jest.mock('../../utils', () => ({
|
|
|
57
60
|
getPackageDependencyVersion: jest.fn(),
|
|
58
61
|
getPackages: jest.fn(),
|
|
59
62
|
getTsConfig: jest.fn(),
|
|
63
|
+
getWebpackConfiguration: jest.fn(),
|
|
60
64
|
isCustomStyleRules: jest.fn(),
|
|
61
65
|
isExposeSharedDependencies: jest.fn(),
|
|
62
66
|
isWebComponent: jest.fn(),
|
|
@@ -120,8 +124,10 @@ describe(`[startup] ${createWebpackConfig.name}`, () => {
|
|
|
120
124
|
jest.mocked(IgnorePlugin).mockImplementation(mockPlugIn('IgnorePlugin'));
|
|
121
125
|
jest.mocked(MomentLocalesPlugin).mockImplementation(mockPlugIn('MomentLocalesPlugin'));
|
|
122
126
|
jest.mocked(ProvidePlugin).mockImplementation(mockPlugIn('ProvidePlugin'));
|
|
127
|
+
jest.mocked(TerserPlugin).mockImplementation(mockPlugIn('TerserPlugin'));
|
|
123
128
|
|
|
124
129
|
jest.mocked(getConfiguration).mockImplementation(() => configuration as any);
|
|
130
|
+
jest.mocked(getWebpackConfiguration).mockImplementation(() => configuration.webpack ?? {});
|
|
125
131
|
jest.mocked(getFolders).mockImplementation((location?: string) => {
|
|
126
132
|
const prefix = location ? `${location.replace(/\W/g, '')}-` : '';
|
|
127
133
|
return { source: `${prefix}${source}`, destination };
|
|
@@ -171,7 +177,7 @@ describe(`[startup] ${createWebpackConfig.name}`, () => {
|
|
|
171
177
|
|
|
172
178
|
test('configures "optimization"', () => {
|
|
173
179
|
expect(subject().optimization).toEqual({
|
|
174
|
-
chunkIds: '
|
|
180
|
+
chunkIds: 'named',
|
|
175
181
|
moduleIds: 'size',
|
|
176
182
|
mangleExports: 'size',
|
|
177
183
|
splitChunks: { cacheGroups: {} },
|
|
@@ -603,24 +609,62 @@ describe(`[startup] ${createWebpackConfig.name}`, () => {
|
|
|
603
609
|
test('configures MiniCssExtractPlugin plugin', () => {
|
|
604
610
|
expect(subject().plugins).toContainEqual(
|
|
605
611
|
new MiniCssExtractPlugin({
|
|
606
|
-
filename: '[name].[contenthash
|
|
612
|
+
filename: '[name].[contenthash].bundle.css',
|
|
607
613
|
...overrides.plugins?.MiniCssExtractPlugin,
|
|
608
614
|
})
|
|
609
615
|
);
|
|
610
616
|
});
|
|
611
617
|
|
|
612
618
|
test('changes "output.filename"', () => {
|
|
613
|
-
expect(subject().output?.filename).toBe('[name].[contenthash
|
|
619
|
+
expect(subject().output?.filename).toBe('[name].[contenthash].bundle.js');
|
|
614
620
|
});
|
|
615
621
|
|
|
616
622
|
test('configures "output.clean"', () => {
|
|
617
623
|
expect(subject().output?.clean).toBe(true);
|
|
618
624
|
});
|
|
619
625
|
|
|
626
|
+
test('changes "optimization.chunkIds" to "deterministic"', () => {
|
|
627
|
+
expect(subject().optimization?.chunkIds).toBe('deterministic');
|
|
628
|
+
});
|
|
629
|
+
|
|
620
630
|
test('configures "optimization.runtimeChunk"', () => {
|
|
621
631
|
expect(subject().optimization?.runtimeChunk).toBe('single');
|
|
622
632
|
});
|
|
623
633
|
|
|
634
|
+
test('configures "optimization.minimize"', () => {
|
|
635
|
+
expect(subject().optimization?.minimize).toBe(true);
|
|
636
|
+
});
|
|
637
|
+
|
|
638
|
+
test('configures "optimization.minimizer"', () => {
|
|
639
|
+
expect(subject().optimization?.minimizer).toEqual([
|
|
640
|
+
new TerserPlugin({ terserOptions: { compress: false, mangle: false } }),
|
|
641
|
+
]);
|
|
642
|
+
});
|
|
643
|
+
|
|
644
|
+
describe('when JS minification is turned off', () => {
|
|
645
|
+
beforeEach(() => (configuration = { webpack: { minify: { js: false } } }));
|
|
646
|
+
|
|
647
|
+
test('changes "optimization.minimize" to false', () => {
|
|
648
|
+
expect(subject().optimization?.minimize).toBe(false);
|
|
649
|
+
});
|
|
650
|
+
|
|
651
|
+
test('omits "optimization.minimizer"', () => {
|
|
652
|
+
expect(subject().optimization?.minimizer).toBeUndefined();
|
|
653
|
+
});
|
|
654
|
+
});
|
|
655
|
+
|
|
656
|
+
describe('with JS minification options', () => {
|
|
657
|
+
beforeEach(() => {
|
|
658
|
+
configuration = { webpack: { minify: { js: { compress: true, mangle: true } } } };
|
|
659
|
+
});
|
|
660
|
+
|
|
661
|
+
test('applies the options', () => {
|
|
662
|
+
expect(subject().optimization?.minimizer).toEqual([
|
|
663
|
+
new TerserPlugin({ terserOptions: configuration.webpack?.minify?.js }),
|
|
664
|
+
]);
|
|
665
|
+
});
|
|
666
|
+
});
|
|
667
|
+
|
|
624
668
|
Object.entries(productionStyleRules).forEach(([extension, rules]) => {
|
|
625
669
|
test(`configures "${extension}" rules`, () => {
|
|
626
670
|
expect(subject().module?.rules).toContainEqual(rules);
|
|
@@ -1,69 +1,109 @@
|
|
|
1
|
+
import TerserPlugin from 'terser-webpack-plugin';
|
|
1
2
|
import { Configuration } from 'webpack';
|
|
2
3
|
import { Context, Overrides } from './types';
|
|
3
4
|
|
|
4
5
|
type Config = Configuration['optimization'];
|
|
6
|
+
type ConfigWithCacheGroups = Config & { splitChunks: { cacheGroups: Record<string, any> } };
|
|
5
7
|
type Result = Pick<Configuration, 'optimization'>;
|
|
6
8
|
|
|
7
9
|
export function optimizationConfig(context: Context, _: Overrides): Result {
|
|
8
|
-
const {
|
|
10
|
+
const { isProduction } = context;
|
|
9
11
|
|
|
10
|
-
const optimization:
|
|
11
|
-
chunkIds: '
|
|
12
|
+
const optimization: ConfigWithCacheGroups = {
|
|
13
|
+
chunkIds: isProduction ? 'deterministic' : 'named',
|
|
12
14
|
moduleIds: 'size',
|
|
13
15
|
mangleExports: 'size',
|
|
14
16
|
splitChunks: { cacheGroups: {} },
|
|
15
17
|
};
|
|
16
18
|
|
|
17
|
-
if (
|
|
18
|
-
|
|
19
|
-
'design-system': {
|
|
20
|
-
test: /[\\/]node_modules[\\/]@servicetitan[\\/](tokens|anvil-fonts|design-system)[\\/].*\.css$/,
|
|
21
|
-
name: 'design-system',
|
|
22
|
-
chunks: 'all',
|
|
23
|
-
enforce: true,
|
|
24
|
-
},
|
|
25
|
-
'anvil2': {
|
|
26
|
-
test: /@servicetitan\/anvil2\/.*\.css$/,
|
|
27
|
-
name: 'anvil2',
|
|
28
|
-
chunks: 'all',
|
|
29
|
-
enforce: true,
|
|
30
|
-
},
|
|
31
|
-
});
|
|
19
|
+
if (isProduction) {
|
|
20
|
+
optimization.runtimeChunk = 'single';
|
|
32
21
|
}
|
|
33
22
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
23
|
+
[minimizeConfig, sharedDependenciesConfig, webComponentConfig].forEach(handler =>
|
|
24
|
+
handler(optimization, context)
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
return { optimization };
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function minimizeConfig(optimization: ConfigWithCacheGroups, context: Context) {
|
|
31
|
+
const { isProduction } = context;
|
|
32
|
+
if (!isProduction) {
|
|
33
|
+
return;
|
|
43
34
|
}
|
|
44
35
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
common: {
|
|
50
|
-
name: 'common',
|
|
51
|
-
test: /[\\/]node_modules[\\/](axios|classnames|formstate|mobx|mobx-react|mobx-utils|react|react-dom|react-router|react-router-dom)[\\/]/,
|
|
52
|
-
chunks: 'all',
|
|
53
|
-
},
|
|
54
|
-
kendo: {
|
|
55
|
-
name: 'kendo',
|
|
56
|
-
test: /[\\/]node_modules[\\/](@progress|@telerik)[\\/]/,
|
|
57
|
-
chunks: 'all',
|
|
58
|
-
},
|
|
59
|
-
servicetitan: {
|
|
60
|
-
name: 'servicetitan',
|
|
61
|
-
test: /[\\/]node_modules[\\/]@servicetitan[\\/]/,
|
|
62
|
-
chunks: 'all',
|
|
63
|
-
},
|
|
64
|
-
});
|
|
65
|
-
}
|
|
36
|
+
const minify = context.minify?.js ?? true;
|
|
37
|
+
optimization.minimize = !!minify;
|
|
38
|
+
if (!optimization.minimize) {
|
|
39
|
+
return;
|
|
66
40
|
}
|
|
67
41
|
|
|
68
|
-
|
|
42
|
+
const terserOptions = {
|
|
43
|
+
compress: false,
|
|
44
|
+
mangle: false,
|
|
45
|
+
...(typeof minify === 'object' ? minify : {}),
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
optimization.minimizer = [new TerserPlugin({ terserOptions })];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function sharedDependenciesConfig(optimization: ConfigWithCacheGroups, context: Context) {
|
|
52
|
+
const { isExposeSharedDependencies } = context;
|
|
53
|
+
if (!isExposeSharedDependencies) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
Object.assign(optimization.splitChunks.cacheGroups, {
|
|
58
|
+
'design-system': {
|
|
59
|
+
test: /[\\/]node_modules[\\/]@servicetitan[\\/](tokens|anvil-fonts|design-system)[\\/].*\.css$/,
|
|
60
|
+
name: 'design-system',
|
|
61
|
+
chunks: 'all',
|
|
62
|
+
enforce: true,
|
|
63
|
+
},
|
|
64
|
+
'anvil2': {
|
|
65
|
+
test: /@servicetitan\/anvil2\/.*\.css$/,
|
|
66
|
+
name: 'anvil2',
|
|
67
|
+
chunks: 'all',
|
|
68
|
+
enforce: true,
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function webComponentConfig(optimization: ConfigWithCacheGroups, context: Context) {
|
|
74
|
+
const { isWebComponent, isProduction } = context;
|
|
75
|
+
if (!isWebComponent) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
Object.assign(optimization.splitChunks.cacheGroups, {
|
|
80
|
+
styles: {
|
|
81
|
+
name: 'main',
|
|
82
|
+
type: 'css/mini-extract',
|
|
83
|
+
chunks: 'all',
|
|
84
|
+
enforce: true,
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
if (!isProduction) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
Object.assign(optimization.splitChunks.cacheGroups, {
|
|
93
|
+
common: {
|
|
94
|
+
name: 'common',
|
|
95
|
+
test: /[\\/]node_modules[\\/](axios|classnames|formstate|mobx|mobx-react|mobx-utils|react|react-dom|react-router|react-router-dom)[\\/]/,
|
|
96
|
+
chunks: 'all',
|
|
97
|
+
},
|
|
98
|
+
kendo: {
|
|
99
|
+
name: 'kendo',
|
|
100
|
+
test: /[\\/]node_modules[\\/](@progress|@telerik)[\\/]/,
|
|
101
|
+
chunks: 'all',
|
|
102
|
+
},
|
|
103
|
+
servicetitan: {
|
|
104
|
+
name: 'servicetitan',
|
|
105
|
+
test: /[\\/]node_modules[\\/]@servicetitan[\\/]/,
|
|
106
|
+
chunks: 'all',
|
|
107
|
+
},
|
|
108
|
+
});
|
|
69
109
|
}
|
|
@@ -18,7 +18,7 @@ export function outputConfig(context: Context, _: Overrides): Result {
|
|
|
18
18
|
if (isProduction) {
|
|
19
19
|
const cdnPath = process.env.CLIENT_CDN_PATH;
|
|
20
20
|
Object.assign(output, {
|
|
21
|
-
filename: '[name].[contenthash
|
|
21
|
+
filename: '[name].[contenthash].bundle.js',
|
|
22
22
|
clean: true,
|
|
23
23
|
...(cdnPath ? { publicPath: cdnPath } : {}),
|
|
24
24
|
});
|
|
@@ -4,16 +4,15 @@ import { Context, Overrides } from '../types';
|
|
|
4
4
|
export function miniCssExtractPlugin(context: Context, overrides: Overrides) {
|
|
5
5
|
const { isCustomStyleRules, isExposeSharedDependencies, isProduction, isWebComponent } =
|
|
6
6
|
context;
|
|
7
|
+
|
|
7
8
|
if (isProduction) {
|
|
8
9
|
if (!isCustomStyleRules) {
|
|
9
10
|
return new MiniCssExtractPlugin({
|
|
10
|
-
filename: '[name].[contenthash
|
|
11
|
+
filename: '[name].[contenthash].bundle.css',
|
|
11
12
|
...(overrides.plugins as any)?.MiniCssExtractPlugin,
|
|
12
13
|
});
|
|
13
14
|
}
|
|
14
|
-
} else {
|
|
15
|
-
|
|
16
|
-
return new MiniCssExtractPlugin({ filename: '[name].bundle.css' });
|
|
17
|
-
}
|
|
15
|
+
} else if (isWebComponent || (isExposeSharedDependencies && !isCustomStyleRules)) {
|
|
16
|
+
return new MiniCssExtractPlugin({ filename: '[name].bundle.css' });
|
|
18
17
|
}
|
|
19
18
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getPackageData, loadSharedDependencies } from '../../utils';
|
|
1
|
+
import { getPackageData, loadSharedDependencies, MinifyOptions } from '../../utils';
|
|
2
2
|
import { Options } from '../types';
|
|
3
3
|
export { Overrides } from '../types';
|
|
4
4
|
|
|
@@ -12,6 +12,7 @@ export interface Context extends Options {
|
|
|
12
12
|
isLegacyRoot: boolean;
|
|
13
13
|
isProduction: boolean;
|
|
14
14
|
isWebComponent: boolean;
|
|
15
|
+
minify?: MinifyOptions;
|
|
15
16
|
packageData: ReturnType<typeof getPackageData>;
|
|
16
17
|
sharedDependencies: ReturnType<typeof loadSharedDependencies>;
|
|
17
18
|
source: string;
|
|
@@ -6,6 +6,7 @@ import { webpackDevConfigFileName, webpackProdConfigFileName } from '../cli/util
|
|
|
6
6
|
import {
|
|
7
7
|
getFolders,
|
|
8
8
|
getPackageData,
|
|
9
|
+
getWebpackConfiguration,
|
|
9
10
|
isCustomStyleRules,
|
|
10
11
|
isExposeSharedDependencies,
|
|
11
12
|
isLegacyRoot,
|
|
@@ -35,6 +36,7 @@ export function createWebpackConfig(overrides: Overrides, options: Options = {})
|
|
|
35
36
|
const { configuration = {} } = overrides;
|
|
36
37
|
|
|
37
38
|
const { source, destination } = getFolders();
|
|
39
|
+
const { minify } = getWebpackConfiguration();
|
|
38
40
|
const packageData = getPackageData();
|
|
39
41
|
const sharedDependencies = loadSharedDependencies(
|
|
40
42
|
packageData.dependencies,
|
|
@@ -52,6 +54,7 @@ export function createWebpackConfig(overrides: Overrides, options: Options = {})
|
|
|
52
54
|
isLegacyRoot: isLegacyRoot(),
|
|
53
55
|
isProduction: configuration.mode === 'production',
|
|
54
56
|
isWebComponent: isWebComponent(),
|
|
57
|
+
minify,
|
|
55
58
|
name: '',
|
|
56
59
|
...options,
|
|
57
60
|
packageData,
|
|
@@ -60,9 +63,7 @@ export function createWebpackConfig(overrides: Overrides, options: Options = {})
|
|
|
60
63
|
};
|
|
61
64
|
|
|
62
65
|
if (context.isWebComponent && isCalledFromCustomWebpackConfigFile()) {
|
|
63
|
-
throw new Error(
|
|
64
|
-
'You cannot call createWebpackConfig in a custom webpack config file in a web component (MFE) project. Export webpack configuration itself as a default export from the config file instead.'
|
|
65
|
-
);
|
|
66
|
+
throw new Error(WEB_COMPONENT_CONFIG_ERROR);
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
const result = merge(
|
|
@@ -115,3 +116,10 @@ function stringify(configuration: any) {
|
|
|
115
116
|
}
|
|
116
117
|
return JSON.stringify(configuration, replacer, 2);
|
|
117
118
|
}
|
|
119
|
+
|
|
120
|
+
const WEB_COMPONENT_CONFIG_ERROR = `
|
|
121
|
+
You cannot call createWebpackConfig in a custom webpack config file in a web component (MFE) project.
|
|
122
|
+
Export webpack configuration itself as a default export from the config file instead.
|
|
123
|
+
`
|
|
124
|
+
.replace(/\n\s*/g, ' ')
|
|
125
|
+
.trim();
|