@servicetitan/startup 22.17.0 → 22.19.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/cli/commands/build.d.ts +3 -2
- package/dist/cli/commands/build.d.ts.map +1 -1
- package/dist/cli/commands/build.js +1 -0
- package/dist/cli/commands/build.js.map +1 -1
- package/dist/cli/commands/bundle-package.d.ts +2 -1
- package/dist/cli/commands/bundle-package.d.ts.map +1 -1
- package/dist/cli/commands/bundle-package.js +4 -3
- package/dist/cli/commands/bundle-package.js.map +1 -1
- package/dist/cli/commands/mfe-publish.d.ts +1 -0
- package/dist/cli/commands/mfe-publish.d.ts.map +1 -1
- package/dist/cli/commands/mfe-publish.js +3 -2
- package/dist/cli/commands/mfe-publish.js.map +1 -1
- package/dist/cli/commands/start.d.ts +3 -2
- package/dist/cli/commands/start.d.ts.map +1 -1
- package/dist/cli/commands/start.js +3 -2
- package/dist/cli/commands/start.js.map +1 -1
- package/dist/cli/utils/bundle.d.ts +7 -2
- package/dist/cli/utils/bundle.d.ts.map +1 -1
- package/dist/cli/utils/bundle.js +28 -58
- package/dist/cli/utils/bundle.js.map +1 -1
- package/dist/cli/utils/set-node-options.d.ts.map +1 -1
- package/dist/cli/utils/set-node-options.js +1 -1
- package/dist/cli/utils/set-node-options.js.map +1 -1
- package/dist/utils/debug.d.ts +5 -0
- package/dist/utils/debug.d.ts.map +1 -0
- package/dist/utils/debug.js +19 -0
- package/dist/utils/debug.js.map +1 -0
- package/dist/utils/get-configuration.d.ts +1 -0
- package/dist/utils/get-configuration.d.ts.map +1 -1
- package/dist/utils/get-configuration.js +6 -1
- package/dist/utils/get-configuration.js.map +1 -1
- package/dist/utils/log.d.ts +6 -0
- package/dist/utils/log.d.ts.map +1 -1
- package/dist/utils/log.js +22 -0
- package/dist/utils/log.js.map +1 -1
- package/dist/webpack/__mocks__/file-rules.d.ts +3 -0
- package/dist/webpack/__mocks__/file-rules.d.ts.map +1 -0
- package/dist/webpack/__mocks__/file-rules.js +31 -0
- package/dist/webpack/__mocks__/file-rules.js.map +1 -0
- package/dist/webpack/__mocks__/index.d.ts +3 -0
- package/dist/webpack/__mocks__/index.d.ts.map +1 -0
- package/dist/webpack/__mocks__/index.js +19 -0
- package/dist/webpack/__mocks__/index.js.map +1 -0
- package/dist/webpack/__mocks__/style-rules.d.ts +8 -0
- package/dist/webpack/__mocks__/style-rules.d.ts.map +1 -0
- package/dist/webpack/__mocks__/style-rules.js +124 -0
- package/dist/webpack/__mocks__/style-rules.js.map +1 -0
- package/dist/webpack/configs/cache-config.d.ts +6 -0
- package/dist/webpack/configs/cache-config.d.ts.map +1 -0
- package/dist/webpack/configs/cache-config.js +24 -0
- package/dist/webpack/configs/cache-config.js.map +1 -0
- package/dist/webpack/configs/dev-server-config.d.ts +6 -0
- package/dist/webpack/configs/dev-server-config.d.ts.map +1 -0
- package/dist/webpack/configs/dev-server-config.js +27 -0
- package/dist/webpack/configs/dev-server-config.js.map +1 -0
- package/dist/webpack/configs/devtool-config.d.ts +6 -0
- package/dist/webpack/configs/devtool-config.d.ts.map +1 -0
- package/dist/webpack/configs/devtool-config.js +16 -0
- package/dist/webpack/configs/devtool-config.js.map +1 -0
- package/dist/webpack/configs/entry.config.d.ts +6 -0
- package/dist/webpack/configs/entry.config.d.ts.map +1 -0
- package/dist/webpack/configs/entry.config.js +14 -0
- package/dist/webpack/configs/entry.config.js.map +1 -0
- package/dist/webpack/configs/externals-config.d.ts +6 -0
- package/dist/webpack/configs/externals-config.d.ts.map +1 -0
- package/dist/webpack/configs/externals-config.js +16 -0
- package/dist/webpack/configs/externals-config.js.map +1 -0
- package/dist/webpack/configs/index.d.ts +13 -0
- package/dist/webpack/configs/index.d.ts.map +1 -0
- package/dist/webpack/configs/index.js +29 -0
- package/dist/webpack/configs/index.js.map +1 -0
- package/dist/webpack/configs/loaders/css-loader.d.ts +14 -0
- package/dist/webpack/configs/loaders/css-loader.d.ts.map +1 -0
- package/dist/webpack/configs/loaders/css-loader.js +17 -0
- package/dist/webpack/configs/loaders/css-loader.js.map +1 -0
- package/dist/webpack/configs/loaders/index.d.ts +5 -0
- package/dist/webpack/configs/loaders/index.d.ts.map +1 -0
- package/dist/webpack/configs/loaders/index.js +21 -0
- package/dist/webpack/configs/loaders/index.js.map +1 -0
- package/dist/webpack/configs/loaders/less-loader.d.ts +9 -0
- package/dist/webpack/configs/loaders/less-loader.d.ts.map +1 -0
- package/dist/webpack/configs/loaders/less-loader.js +8 -0
- package/dist/webpack/configs/loaders/less-loader.js.map +1 -0
- package/dist/webpack/configs/loaders/style-loader.d.ts +9 -0
- package/dist/webpack/configs/loaders/style-loader.d.ts.map +1 -0
- package/dist/webpack/configs/loaders/style-loader.js +13 -0
- package/dist/webpack/configs/loaders/style-loader.js.map +1 -0
- package/dist/webpack/configs/loaders/types.d.ts +4 -0
- package/dist/webpack/configs/loaders/types.d.ts.map +1 -0
- package/dist/webpack/configs/loaders/types.js +3 -0
- package/dist/webpack/configs/loaders/types.js.map +1 -0
- package/dist/webpack/configs/module-config.d.ts +6 -0
- package/dist/webpack/configs/module-config.d.ts.map +1 -0
- package/dist/webpack/configs/module-config.js +10 -0
- package/dist/webpack/configs/module-config.js.map +1 -0
- package/dist/webpack/configs/optimization-config.d.ts +6 -0
- package/dist/webpack/configs/optimization-config.d.ts.map +1 -0
- package/dist/webpack/configs/optimization-config.js +57 -0
- package/dist/webpack/configs/optimization-config.js.map +1 -0
- package/dist/webpack/configs/output-config.d.ts +6 -0
- package/dist/webpack/configs/output-config.d.ts.map +1 -0
- package/dist/webpack/configs/output-config.js +23 -0
- package/dist/webpack/configs/output-config.js.map +1 -0
- package/dist/webpack/configs/plugins/assets-manifest-plugin.d.ts +4 -0
- package/dist/webpack/configs/plugins/assets-manifest-plugin.d.ts.map +1 -0
- package/dist/webpack/configs/plugins/assets-manifest-plugin.js +34 -0
- package/dist/webpack/configs/plugins/assets-manifest-plugin.js.map +1 -0
- package/dist/webpack/configs/plugins/bundle-analyser-plugin.d.ts +3 -0
- package/dist/webpack/configs/plugins/bundle-analyser-plugin.d.ts.map +1 -0
- package/dist/webpack/configs/plugins/bundle-analyser-plugin.js +20 -0
- package/dist/webpack/configs/plugins/bundle-analyser-plugin.js.map +1 -0
- package/dist/webpack/configs/plugins/define-exposed-dependencies-plugin.d.ts +4 -0
- package/dist/webpack/configs/plugins/define-exposed-dependencies-plugin.d.ts.map +1 -0
- package/dist/webpack/configs/plugins/define-exposed-dependencies-plugin.js +25 -0
- package/dist/webpack/configs/plugins/define-exposed-dependencies-plugin.js.map +1 -0
- package/dist/webpack/configs/plugins/define-web-component-name-plugin.d.ts +4 -0
- package/dist/webpack/configs/plugins/define-web-component-name-plugin.d.ts.map +1 -0
- package/dist/webpack/configs/plugins/define-web-component-name-plugin.js +16 -0
- package/dist/webpack/configs/plugins/define-web-component-name-plugin.js.map +1 -0
- package/dist/webpack/configs/plugins/filter-warnings-plugin.d.ts +3 -0
- package/dist/webpack/configs/plugins/filter-warnings-plugin.d.ts.map +1 -0
- package/dist/webpack/configs/plugins/filter-warnings-plugin.js +14 -0
- package/dist/webpack/configs/plugins/filter-warnings-plugin.js.map +1 -0
- package/dist/webpack/configs/plugins/html-plugin.d.ts +4 -0
- package/dist/webpack/configs/plugins/html-plugin.d.ts.map +1 -0
- package/dist/webpack/configs/plugins/html-plugin.js +42 -0
- package/dist/webpack/configs/plugins/html-plugin.js.map +1 -0
- package/dist/webpack/configs/plugins/index.d.ts +12 -0
- package/dist/webpack/configs/plugins/index.d.ts.map +1 -0
- package/dist/webpack/configs/plugins/index.js +28 -0
- package/dist/webpack/configs/plugins/index.js.map +1 -0
- package/dist/webpack/configs/plugins/mini-css-extract-plugin.d.ts +4 -0
- package/dist/webpack/configs/plugins/mini-css-extract-plugin.d.ts.map +1 -0
- package/dist/webpack/configs/plugins/mini-css-extract-plugin.js +23 -0
- package/dist/webpack/configs/plugins/mini-css-extract-plugin.js.map +1 -0
- package/dist/webpack/configs/plugins/moment-locales-plugin.d.ts +4 -0
- package/dist/webpack/configs/plugins/moment-locales-plugin.d.ts.map +1 -0
- package/dist/webpack/configs/plugins/moment-locales-plugin.js +14 -0
- package/dist/webpack/configs/plugins/moment-locales-plugin.js.map +1 -0
- package/dist/webpack/configs/plugins/provide-react-plugin.d.ts +4 -0
- package/dist/webpack/configs/plugins/provide-react-plugin.d.ts.map +1 -0
- package/dist/webpack/configs/plugins/provide-react-plugin.js +14 -0
- package/dist/webpack/configs/plugins/provide-react-plugin.js.map +1 -0
- package/dist/webpack/configs/plugins/ts-checker-plugin.d.ts +4 -0
- package/dist/webpack/configs/plugins/ts-checker-plugin.d.ts.map +1 -0
- package/dist/webpack/configs/plugins/ts-checker-plugin.js +31 -0
- package/dist/webpack/configs/plugins/ts-checker-plugin.js.map +1 -0
- package/dist/webpack/configs/plugins/virtual-modules-plugin.d.ts +4 -0
- package/dist/webpack/configs/plugins/virtual-modules-plugin.d.ts.map +1 -0
- package/dist/webpack/configs/plugins/virtual-modules-plugin.js +42 -0
- package/dist/webpack/configs/plugins/virtual-modules-plugin.js.map +1 -0
- package/dist/webpack/configs/plugins-config.d.ts +6 -0
- package/dist/webpack/configs/plugins-config.d.ts.map +1 -0
- package/dist/webpack/configs/plugins-config.js +24 -0
- package/dist/webpack/configs/plugins-config.js.map +1 -0
- package/dist/webpack/configs/resolve-config.d.ts +6 -0
- package/dist/webpack/configs/resolve-config.d.ts.map +1 -0
- package/dist/webpack/configs/resolve-config.js +11 -0
- package/dist/webpack/configs/resolve-config.js.map +1 -0
- package/dist/webpack/configs/rules/css-rules.d.ts +4 -0
- package/dist/webpack/configs/rules/css-rules.d.ts.map +1 -0
- package/dist/webpack/configs/rules/css-rules.js +35 -0
- package/dist/webpack/configs/rules/css-rules.js.map +1 -0
- package/dist/webpack/configs/rules/font-rules.d.ts +4 -0
- package/dist/webpack/configs/rules/font-rules.d.ts.map +1 -0
- package/dist/webpack/configs/rules/font-rules.js +16 -0
- package/dist/webpack/configs/rules/font-rules.js.map +1 -0
- package/dist/webpack/configs/rules/image-rules.d.ts +4 -0
- package/dist/webpack/configs/rules/image-rules.d.ts.map +1 -0
- package/dist/webpack/configs/rules/image-rules.js +16 -0
- package/dist/webpack/configs/rules/image-rules.js.map +1 -0
- package/dist/webpack/configs/rules/index.d.ts +8 -0
- package/dist/webpack/configs/rules/index.d.ts.map +1 -0
- package/dist/webpack/configs/rules/index.js +24 -0
- package/dist/webpack/configs/rules/index.js.map +1 -0
- package/dist/webpack/configs/rules/js-rules.d.ts +4 -0
- package/dist/webpack/configs/rules/js-rules.d.ts.map +1 -0
- package/dist/webpack/configs/rules/js-rules.js +19 -0
- package/dist/webpack/configs/rules/js-rules.js.map +1 -0
- package/dist/webpack/configs/rules/less-rules.d.ts +4 -0
- package/dist/webpack/configs/rules/less-rules.d.ts.map +1 -0
- package/dist/webpack/configs/rules/less-rules.js +23 -0
- package/dist/webpack/configs/rules/less-rules.js.map +1 -0
- package/dist/webpack/configs/rules/scss-rules.d.ts +4 -0
- package/dist/webpack/configs/rules/scss-rules.d.ts.map +1 -0
- package/dist/webpack/configs/rules/scss-rules.js +23 -0
- package/dist/webpack/configs/rules/scss-rules.js.map +1 -0
- package/dist/webpack/configs/rules/tsx-rules.d.ts +4 -0
- package/dist/webpack/configs/rules/tsx-rules.d.ts.map +1 -0
- package/dist/webpack/configs/rules/tsx-rules.js +23 -0
- package/dist/webpack/configs/rules/tsx-rules.js.map +1 -0
- package/dist/webpack/configs/rules-config.d.ts +9 -0
- package/dist/webpack/configs/rules-config.d.ts.map +1 -0
- package/dist/webpack/configs/rules-config.js +31 -0
- package/dist/webpack/configs/rules-config.js.map +1 -0
- package/dist/webpack/configs/stats-config.d.ts +6 -0
- package/dist/webpack/configs/stats-config.d.ts.map +1 -0
- package/dist/webpack/configs/stats-config.js +16 -0
- package/dist/webpack/configs/stats-config.js.map +1 -0
- package/dist/webpack/configs/types.d.ts +15 -0
- package/dist/webpack/configs/types.d.ts.map +1 -0
- package/dist/webpack/configs/types.js +3 -0
- package/dist/webpack/configs/types.js.map +1 -0
- package/dist/webpack/configs/utils/generate-metadata.d.ts +3 -0
- package/dist/webpack/configs/utils/generate-metadata.d.ts.map +1 -0
- package/dist/webpack/configs/utils/generate-metadata.js +31 -0
- package/dist/webpack/configs/utils/generate-metadata.js.map +1 -0
- package/dist/webpack/configs/utils/get-startup-version.d.ts +2 -0
- package/dist/webpack/configs/utils/get-startup-version.d.ts.map +1 -0
- package/dist/webpack/configs/utils/get-startup-version.js +13 -0
- package/dist/webpack/configs/utils/get-startup-version.js.map +1 -0
- package/dist/webpack/configs/utils/index.d.ts +2 -0
- package/dist/webpack/configs/utils/index.d.ts.map +1 -0
- package/dist/webpack/configs/utils/index.js +18 -0
- package/dist/webpack/configs/utils/index.js.map +1 -0
- package/dist/webpack/create-webpack-config.d.ts +4 -0
- package/dist/webpack/create-webpack-config.d.ts.map +1 -0
- package/dist/webpack/create-webpack-config.js +67 -0
- package/dist/webpack/create-webpack-config.js.map +1 -0
- package/dist/webpack/index.d.ts +2 -10
- package/dist/webpack/index.d.ts.map +1 -1
- package/dist/webpack/index.js +16 -21
- package/dist/webpack/index.js.map +1 -1
- package/dist/webpack/types.d.ts +18 -0
- package/dist/webpack/types.d.ts.map +1 -0
- package/dist/webpack/types.js +3 -0
- package/dist/webpack/types.js.map +1 -0
- package/dist/webpack/utils/index.d.ts +5 -0
- package/dist/webpack/utils/index.d.ts.map +1 -0
- package/dist/webpack/utils/index.js +21 -0
- package/dist/webpack/utils/index.js.map +1 -0
- package/package.json +5 -4
- package/src/cli/commands/__tests__/build.test.ts +13 -0
- package/src/cli/commands/__tests__/bundle-package.test.ts +27 -4
- package/src/cli/commands/__tests__/mfe-package-publish.test.ts +10 -0
- package/src/cli/commands/__tests__/mfe-publish.test.ts +1 -0
- package/src/cli/commands/__tests__/start.test.ts +15 -0
- package/src/cli/commands/build.ts +4 -2
- package/src/cli/commands/bundle-package.ts +7 -4
- package/src/cli/commands/mfe-publish.ts +3 -1
- package/src/cli/commands/start.ts +6 -4
- package/src/cli/utils/__tests__/bundle.test.ts +142 -111
- package/src/cli/utils/__tests__/set-node-options.test.ts +4 -4
- package/src/cli/utils/bundle.ts +37 -118
- package/src/cli/utils/set-node-options.ts +2 -2
- package/src/utils/__tests__/get-configuration.test.ts +46 -0
- package/src/utils/__tests__/log.test.ts +43 -1
- package/src/utils/debug.ts +13 -0
- package/src/utils/get-configuration.ts +5 -1
- package/src/utils/log.ts +22 -0
- package/src/webpack/__mocks__/file-rules.ts +29 -0
- package/src/webpack/__mocks__/index.ts +2 -0
- package/src/webpack/__mocks__/style-rules.ts +126 -0
- package/src/webpack/__tests__/create-webpack-config-shared-dependencies.test.ts +162 -0
- package/src/webpack/__tests__/create-webpack-config-web-component.test.ts +331 -0
- package/src/webpack/__tests__/create-webpack-config.test.ts +400 -42
- package/src/webpack/configs/cache-config.ts +25 -0
- package/src/webpack/configs/dev-server-config.ts +43 -0
- package/src/webpack/configs/devtool-config.ts +18 -0
- package/src/webpack/configs/entry.config.ts +18 -0
- package/src/webpack/configs/externals-config.ts +21 -0
- package/src/webpack/configs/index.ts +12 -0
- package/src/webpack/configs/loaders/css-loader.ts +19 -0
- package/src/webpack/configs/loaders/index.ts +4 -0
- package/src/webpack/configs/loaders/less-loader.ts +3 -0
- package/src/webpack/configs/loaders/style-loader.ts +11 -0
- package/src/webpack/configs/loaders/types.ts +3 -0
- package/src/webpack/configs/module-config.ts +12 -0
- package/src/webpack/configs/optimization-config.ts +63 -0
- package/src/webpack/configs/output-config.ts +28 -0
- package/src/webpack/configs/plugins/assets-manifest-plugin.ts +34 -0
- package/src/webpack/configs/plugins/bundle-analyser-plugin.ts +18 -0
- package/src/webpack/configs/plugins/define-exposed-dependencies-plugin.ts +29 -0
- package/src/webpack/configs/plugins/define-web-component-name-plugin.ts +14 -0
- package/src/webpack/configs/plugins/filter-warnings-plugin.ts +12 -0
- package/src/webpack/configs/plugins/html-plugin.ts +53 -0
- package/src/webpack/configs/plugins/index.ts +11 -0
- package/src/webpack/configs/plugins/mini-css-extract-plugin.ts +19 -0
- package/src/webpack/configs/plugins/moment-locales-plugin.ts +8 -0
- package/src/webpack/configs/plugins/provide-react-plugin.ts +12 -0
- package/src/webpack/configs/plugins/ts-checker-plugin.ts +33 -0
- package/src/webpack/configs/plugins/virtual-modules-plugin.ts +42 -0
- package/src/webpack/configs/plugins-config.ts +38 -0
- package/src/webpack/configs/resolve-config.ts +13 -0
- package/src/webpack/configs/rules/css-rules.ts +36 -0
- package/src/webpack/configs/rules/font-rules.ts +14 -0
- package/src/webpack/configs/rules/image-rules.ts +14 -0
- package/src/webpack/configs/rules/index.ts +7 -0
- package/src/webpack/configs/rules/js-rules.ts +17 -0
- package/src/webpack/configs/rules/less-rules.ts +21 -0
- package/src/webpack/configs/rules/scss-rules.ts +21 -0
- package/src/webpack/configs/rules/tsx-rules.ts +22 -0
- package/src/webpack/configs/rules-config.ts +38 -0
- package/src/webpack/configs/stats-config.ts +18 -0
- package/src/webpack/configs/types.ts +15 -0
- package/src/webpack/configs/utils/__tests__/generate-metadata.test.ts +77 -0
- package/src/webpack/configs/utils/__tests__/get-startup-version.test.ts +27 -0
- package/src/webpack/configs/utils/generate-metadata.ts +30 -0
- package/src/webpack/configs/utils/get-startup-version.ts +8 -0
- package/src/webpack/configs/utils/index.ts +1 -0
- package/src/webpack/create-webpack-config.ts +110 -0
- package/src/webpack/index.ts +2 -52
- package/{dist/webpack/shared.config.d.ts → src/webpack/types.ts} +10 -4
- package/src/webpack/utils/index.ts +4 -0
- package/dist/webpack/development.config.d.ts +0 -11
- package/dist/webpack/development.config.d.ts.map +0 -1
- package/dist/webpack/development.config.js +0 -191
- package/dist/webpack/development.config.js.map +0 -1
- package/dist/webpack/production.config.d.ts +0 -14
- package/dist/webpack/production.config.d.ts.map +0 -1
- package/dist/webpack/production.config.js +0 -172
- package/dist/webpack/production.config.js.map +0 -1
- package/dist/webpack/shared.config.d.ts.map +0 -1
- package/dist/webpack/shared.config.js +0 -268
- package/dist/webpack/shared.config.js.map +0 -1
- package/src/webpack/__tests__/create-development-config.test.ts +0 -306
- package/src/webpack/__tests__/create-production-config.test.ts +0 -231
- package/src/webpack/__tests__/create-shared-config.test.ts +0 -508
- package/src/webpack/development.config.ts +0 -237
- package/src/webpack/production.config.ts +0 -197
- package/src/webpack/shared.config.ts +0 -360
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Configuration } from 'webpack';
|
|
2
|
+
import { rulesConfig } from './rules-config';
|
|
3
|
+
import { Context, Overrides } from './types';
|
|
4
|
+
|
|
5
|
+
type Config = Configuration['module'];
|
|
6
|
+
type Result = Pick<Configuration, 'module'>;
|
|
7
|
+
|
|
8
|
+
export function moduleConfig(context: Context, overrides: Overrides): Result {
|
|
9
|
+
const module: Config = { ...rulesConfig(context, overrides) };
|
|
10
|
+
|
|
11
|
+
return { module };
|
|
12
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Configuration } from 'webpack';
|
|
2
|
+
import { Context, Overrides } from './types';
|
|
3
|
+
|
|
4
|
+
type Config = Configuration['optimization'];
|
|
5
|
+
type Result = Pick<Configuration, 'optimization'>;
|
|
6
|
+
|
|
7
|
+
export function optimizationConfig(context: Context, _: Overrides): Result {
|
|
8
|
+
const { isExposeSharedDependencies, isProduction, isWebComponent } = context;
|
|
9
|
+
|
|
10
|
+
const optimization: Config & { splitChunks: { cacheGroups: Record<string, any> } } = {
|
|
11
|
+
chunkIds: 'size',
|
|
12
|
+
moduleIds: 'size',
|
|
13
|
+
mangleExports: 'size',
|
|
14
|
+
splitChunks: { cacheGroups: {} },
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
if (isExposeSharedDependencies) {
|
|
18
|
+
Object.assign(optimization.splitChunks.cacheGroups, {
|
|
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
|
+
});
|
|
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
|
+
|
|
39
|
+
if (isProduction) {
|
|
40
|
+
optimization.runtimeChunk = 'single';
|
|
41
|
+
if (isWebComponent) {
|
|
42
|
+
Object.assign(optimization.splitChunks.cacheGroups, {
|
|
43
|
+
common: {
|
|
44
|
+
name: 'common',
|
|
45
|
+
test: /[\\/]node_modules[\\/](axios|classnames|formstate|mobx|mobx-react|mobx-utils|react|react-dom|react-router|react-router-dom)[\\/]/,
|
|
46
|
+
chunks: 'all',
|
|
47
|
+
},
|
|
48
|
+
kendo: {
|
|
49
|
+
name: 'kendo',
|
|
50
|
+
test: /[\\/]node_modules[\\/](@progress|@telerik)[\\/]/,
|
|
51
|
+
chunks: 'all',
|
|
52
|
+
},
|
|
53
|
+
servicetitan: {
|
|
54
|
+
name: 'servicetitan',
|
|
55
|
+
test: /[\\/]node_modules[\\/]@servicetitan[\\/]/,
|
|
56
|
+
chunks: 'all',
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return { optimization };
|
|
63
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { Configuration } from 'webpack';
|
|
3
|
+
import { Context, Overrides } from './types';
|
|
4
|
+
|
|
5
|
+
type Config = Configuration['output'];
|
|
6
|
+
type Result = Pick<Configuration, 'output'>;
|
|
7
|
+
|
|
8
|
+
export function outputConfig(context: Context, _: Overrides): Result {
|
|
9
|
+
const { destination, embed, isProduction, isWebComponent } = context;
|
|
10
|
+
|
|
11
|
+
const output: Config = {
|
|
12
|
+
filename: '[name].bundle.js',
|
|
13
|
+
path: isWebComponent
|
|
14
|
+
? path.join(process.cwd(), `${destination}/bundle/${embed ? 'light' : 'full'}`)
|
|
15
|
+
: path.join(process.cwd(), `${destination}/bundle`),
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
if (isProduction) {
|
|
19
|
+
const cdnPath = process.env.CLIENT_CDN_PATH;
|
|
20
|
+
Object.assign(output, {
|
|
21
|
+
filename: '[name].[contenthash:8].bundle.js',
|
|
22
|
+
clean: true,
|
|
23
|
+
...(cdnPath ? { publicPath: cdnPath } : {}),
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return { output };
|
|
28
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import WebpackAssetsManifest from 'webpack-assets-manifest';
|
|
2
|
+
import { Context, Overrides } from '../types';
|
|
3
|
+
import { generateMetadata } from '../utils';
|
|
4
|
+
|
|
5
|
+
export function assetsManifestPlugin(context: Context, _: Overrides) {
|
|
6
|
+
if (!context.isWebComponent) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
return new WebpackAssetsManifest({
|
|
11
|
+
entrypoints: true,
|
|
12
|
+
output: 'entrypoints.json',
|
|
13
|
+
transform(assets) {
|
|
14
|
+
const entrypoints = assets.entrypoints as Record<
|
|
15
|
+
string,
|
|
16
|
+
{ assets: Record<string, string[]> }
|
|
17
|
+
>;
|
|
18
|
+
|
|
19
|
+
const getAssetsByType = (type: string) => {
|
|
20
|
+
return Object.values(entrypoints)
|
|
21
|
+
.map(({ assets }) => assets[type] ?? [])
|
|
22
|
+
.flat();
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return {
|
|
26
|
+
css: getAssetsByType('css'),
|
|
27
|
+
js: getAssetsByType('js'),
|
|
28
|
+
};
|
|
29
|
+
},
|
|
30
|
+
done(_manifest) {
|
|
31
|
+
generateMetadata(context);
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import os from 'os';
|
|
3
|
+
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
|
4
|
+
import { Context, Overrides } from '../types';
|
|
5
|
+
|
|
6
|
+
export function bundleAnalyzerPlugin({ buildStat, embed }: Context, _: Overrides) {
|
|
7
|
+
if (!buildStat) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
return new BundleAnalyzerPlugin({
|
|
12
|
+
analyzerMode: 'static',
|
|
13
|
+
reportFilename: path.join(
|
|
14
|
+
os.tmpdir(),
|
|
15
|
+
`report-${embed ? 'light' : 'full'}-bundle-${Date.now()}.html`
|
|
16
|
+
),
|
|
17
|
+
});
|
|
18
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { DefinePlugin } from 'webpack';
|
|
2
|
+
import { getPackageDependencyVersion } from '../../../utils';
|
|
3
|
+
import { Context, Overrides } from '../types';
|
|
4
|
+
|
|
5
|
+
export function defineExposedDependenciesPlugin(context: Context, _: Overrides) {
|
|
6
|
+
const { isExposeSharedDependencies, packageData, sharedDependencies } = context;
|
|
7
|
+
if (!isExposeSharedDependencies) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
return new DefinePlugin({
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
13
|
+
EXPOSED_DEPENDENCIES: JSON.stringify(
|
|
14
|
+
Object.entries(sharedDependencies).reduce(
|
|
15
|
+
(result, [dependency, variable]) =>
|
|
16
|
+
Object.assign(result, {
|
|
17
|
+
[dependency]: {
|
|
18
|
+
version: getPackageDependencyVersion(
|
|
19
|
+
dependency,
|
|
20
|
+
packageData.dependencies?.[dependency]
|
|
21
|
+
),
|
|
22
|
+
variable,
|
|
23
|
+
},
|
|
24
|
+
}),
|
|
25
|
+
{}
|
|
26
|
+
)
|
|
27
|
+
),
|
|
28
|
+
});
|
|
29
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DefinePlugin } from 'webpack';
|
|
2
|
+
import { Context, Overrides } from '../types';
|
|
3
|
+
|
|
4
|
+
export function defineWebComponentNamePlugin(context: Context, _: Overrides) {
|
|
5
|
+
const { isWebComponent, name } = context;
|
|
6
|
+
if (!isWebComponent) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
return new DefinePlugin({
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
12
|
+
WEB_COMPONENT_NAME: JSON.stringify(name),
|
|
13
|
+
});
|
|
14
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const FilterWarningsPlugin = require('webpack-filter-warnings-plugin');
|
|
2
|
+
import { Context, Overrides } from '../types';
|
|
3
|
+
|
|
4
|
+
export function filterWarningsPlugin({ embed }: Context, _: Overrides) {
|
|
5
|
+
if (embed) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
return new FilterWarningsPlugin({
|
|
10
|
+
exclude: /export .* was not found in/,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import deepmerge from 'deepmerge';
|
|
2
|
+
import HtmlWebpackPlugin, { Options as HtmlWebpackPluginOptions } from 'html-webpack-plugin';
|
|
3
|
+
import { splitByEntry } from '../../utils';
|
|
4
|
+
import { Context, Overrides } from '../types';
|
|
5
|
+
|
|
6
|
+
export function htmlPlugin({ embed, isWebComponent, name }: Context, { plugins }: Overrides) {
|
|
7
|
+
const { HtmlWebpackPlugin: htmlWebpackPluginOptions = {} } = plugins ?? {};
|
|
8
|
+
|
|
9
|
+
if (embed) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return new HtmlWebpackPlugin(
|
|
14
|
+
deepmerge<HtmlWebpackPluginOptions>(
|
|
15
|
+
{
|
|
16
|
+
title: 'ServiceTitan',
|
|
17
|
+
hash: true,
|
|
18
|
+
...(isWebComponent
|
|
19
|
+
? {
|
|
20
|
+
inject: false,
|
|
21
|
+
publicPath: '/',
|
|
22
|
+
templateContent: ({
|
|
23
|
+
htmlWebpackPlugin: {
|
|
24
|
+
tags: { headTags, bodyTags },
|
|
25
|
+
files,
|
|
26
|
+
},
|
|
27
|
+
}) => {
|
|
28
|
+
const styleUrls = encodeURIComponent(JSON.stringify(files.css));
|
|
29
|
+
return `
|
|
30
|
+
<!DOCTYPE html>
|
|
31
|
+
<html>
|
|
32
|
+
<head>
|
|
33
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
34
|
+
${headTags}
|
|
35
|
+
</head>
|
|
36
|
+
<body>
|
|
37
|
+
<${name} style-urls="${styleUrls}" />
|
|
38
|
+
|
|
39
|
+
${bodyTags}
|
|
40
|
+
</body>
|
|
41
|
+
</html>
|
|
42
|
+
`;
|
|
43
|
+
},
|
|
44
|
+
}
|
|
45
|
+
: {}),
|
|
46
|
+
templateParameters: {
|
|
47
|
+
splitByEntry,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
htmlWebpackPluginOptions
|
|
51
|
+
)
|
|
52
|
+
);
|
|
53
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './assets-manifest-plugin';
|
|
2
|
+
export * from './bundle-analyser-plugin';
|
|
3
|
+
export * from './define-exposed-dependencies-plugin';
|
|
4
|
+
export * from './define-web-component-name-plugin';
|
|
5
|
+
export * from './filter-warnings-plugin';
|
|
6
|
+
export * from './html-plugin';
|
|
7
|
+
export * from './mini-css-extract-plugin';
|
|
8
|
+
export * from './moment-locales-plugin';
|
|
9
|
+
export * from './provide-react-plugin';
|
|
10
|
+
export * from './ts-checker-plugin';
|
|
11
|
+
export * from './virtual-modules-plugin';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
|
|
2
|
+
import { Context, Overrides } from '../types';
|
|
3
|
+
|
|
4
|
+
export function miniCssExtractPlugin(context: Context, overrides: Overrides) {
|
|
5
|
+
const { isCustomStyleRules, isExposeSharedDependencies, isProduction, isWebComponent } =
|
|
6
|
+
context;
|
|
7
|
+
if (isProduction) {
|
|
8
|
+
if (!isCustomStyleRules) {
|
|
9
|
+
return new MiniCssExtractPlugin({
|
|
10
|
+
filename: '[name].[contenthash:8].bundle.css',
|
|
11
|
+
...(overrides.plugins as any)?.MiniCssExtractPlugin,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
} else {
|
|
15
|
+
if (isWebComponent || (isExposeSharedDependencies && !isCustomStyleRules)) {
|
|
16
|
+
return new MiniCssExtractPlugin({ filename: '[name].bundle.css' });
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import MomentLocalesPlugin from 'moment-locales-webpack-plugin';
|
|
2
|
+
import { Context, Overrides } from '../types';
|
|
3
|
+
|
|
4
|
+
export function momentLocalesPlugin(_: Context, _overrides: Overrides) {
|
|
5
|
+
return new MomentLocalesPlugin({
|
|
6
|
+
localesToKeep: ['en-au', 'en-ca', 'en-gb'],
|
|
7
|
+
});
|
|
8
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ProvidePlugin } from 'webpack';
|
|
2
|
+
import { Context, Overrides } from '../types';
|
|
3
|
+
|
|
4
|
+
export function provideReactPlugin({ esbuild }: Context, _: Overrides) {
|
|
5
|
+
if (!esbuild) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
return new ProvidePlugin({
|
|
10
|
+
React: 'react',
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import deepmerge from 'deepmerge';
|
|
2
|
+
import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';
|
|
3
|
+
import { ForkTsCheckerWebpackPluginOptions } from 'fork-ts-checker-webpack-plugin/lib/plugin-options';
|
|
4
|
+
import { getTsConfig } from '../../../utils';
|
|
5
|
+
import { Context, Overrides } from '../types';
|
|
6
|
+
|
|
7
|
+
export function tsCheckerPlugin({ embed }: Context, { plugins }: Overrides) {
|
|
8
|
+
const { ForkTsCheckerWebpackPlugin: forkTsCheckerWebpackPluginOptions = {} } = plugins ?? {};
|
|
9
|
+
|
|
10
|
+
if (embed) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return new ForkTsCheckerWebpackPlugin(
|
|
15
|
+
deepmerge<ForkTsCheckerWebpackPluginOptions>(
|
|
16
|
+
{
|
|
17
|
+
typescript: {
|
|
18
|
+
configFile: getTsConfig(),
|
|
19
|
+
configOverwrite: {
|
|
20
|
+
exclude: [
|
|
21
|
+
'**/__tests__/**/*',
|
|
22
|
+
'**/__mocks__/**/*',
|
|
23
|
+
'**/*.test.*',
|
|
24
|
+
'**/*.stories.tsx',
|
|
25
|
+
],
|
|
26
|
+
references: [],
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
forkTsCheckerWebpackPluginOptions
|
|
31
|
+
)
|
|
32
|
+
);
|
|
33
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import VirtualModulesPlugin from 'webpack-virtual-modules';
|
|
4
|
+
import { Context, Overrides } from '../types';
|
|
5
|
+
|
|
6
|
+
export function virtualModulesPlugin(context: Context, _: Overrides) {
|
|
7
|
+
if (!context.isWebComponent) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const { source } = context;
|
|
12
|
+
|
|
13
|
+
const indexPath = path.join(process.cwd(), `${source}/index.ts`);
|
|
14
|
+
const modules: ConstructorParameters<typeof VirtualModulesPlugin>[0] = {
|
|
15
|
+
[indexPath]: indexCode(context),
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const designSystemPath = path.join(process.cwd(), `${source}/design-system.css`);
|
|
19
|
+
if (!fs.existsSync(designSystemPath)) {
|
|
20
|
+
modules[designSystemPath] = designSystemCode();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return new VirtualModulesPlugin(modules);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function designSystemCode() {
|
|
27
|
+
return [
|
|
28
|
+
`@import '~@servicetitan/tokens/core/tokens.css';`,
|
|
29
|
+
`@import '~@servicetitan/anvil-fonts/dist/css/anvil-fonts.css';`,
|
|
30
|
+
`@import '~@servicetitan/design-system/dist/system.min.css';`,
|
|
31
|
+
].join('\n');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function indexCode({ embed }: Context) {
|
|
35
|
+
return [
|
|
36
|
+
`import { register } from '@servicetitan/web-components';`,
|
|
37
|
+
`import { App } from './app';`,
|
|
38
|
+
...(embed
|
|
39
|
+
? [`register(App, true);`]
|
|
40
|
+
: [`require('./design-system.css');`, `register(App, false);`]),
|
|
41
|
+
].join('\n');
|
|
42
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Configuration } from 'webpack';
|
|
2
|
+
import {
|
|
3
|
+
assetsManifestPlugin,
|
|
4
|
+
bundleAnalyzerPlugin,
|
|
5
|
+
defineExposedDependenciesPlugin,
|
|
6
|
+
defineWebComponentNamePlugin,
|
|
7
|
+
filterWarningsPlugin,
|
|
8
|
+
htmlPlugin,
|
|
9
|
+
miniCssExtractPlugin,
|
|
10
|
+
momentLocalesPlugin,
|
|
11
|
+
provideReactPlugin,
|
|
12
|
+
tsCheckerPlugin,
|
|
13
|
+
virtualModulesPlugin,
|
|
14
|
+
} from './plugins';
|
|
15
|
+
import { Context, Overrides } from './types';
|
|
16
|
+
|
|
17
|
+
type Config = Configuration['plugins'];
|
|
18
|
+
type Result = Pick<Configuration, 'plugins'>;
|
|
19
|
+
|
|
20
|
+
export function pluginsConfig(context: Context, overrides: Overrides): Result {
|
|
21
|
+
const plugins: Config = [
|
|
22
|
+
assetsManifestPlugin,
|
|
23
|
+
bundleAnalyzerPlugin,
|
|
24
|
+
defineExposedDependenciesPlugin,
|
|
25
|
+
defineWebComponentNamePlugin,
|
|
26
|
+
filterWarningsPlugin,
|
|
27
|
+
htmlPlugin,
|
|
28
|
+
miniCssExtractPlugin,
|
|
29
|
+
momentLocalesPlugin,
|
|
30
|
+
tsCheckerPlugin,
|
|
31
|
+
provideReactPlugin,
|
|
32
|
+
virtualModulesPlugin,
|
|
33
|
+
]
|
|
34
|
+
.map(fn => fn(context, overrides))
|
|
35
|
+
.filter(plugin => !!plugin);
|
|
36
|
+
|
|
37
|
+
return { plugins };
|
|
38
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Configuration } from 'webpack';
|
|
2
|
+
import { Context, Overrides } from './types';
|
|
3
|
+
|
|
4
|
+
type Config = Configuration['resolve'];
|
|
5
|
+
type Result = Pick<Configuration, 'resolve'>;
|
|
6
|
+
|
|
7
|
+
export function resolveConfig(_context: Context, _: Overrides): Result {
|
|
8
|
+
const resolve: Config = {
|
|
9
|
+
extensions: ['.js', '.jsx', '.ts', '.tsx'],
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
return { resolve };
|
|
13
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
|
|
2
|
+
import { RuleSetRule } from 'webpack';
|
|
3
|
+
import { cssLoader, styleLoader } from '../loaders';
|
|
4
|
+
import { Context } from '../types';
|
|
5
|
+
|
|
6
|
+
export function cssRules(context: Context): RuleSetRule[] {
|
|
7
|
+
const { isExposeSharedDependencies, isProduction } = context;
|
|
8
|
+
|
|
9
|
+
const excludeCallback = (path: string) => {
|
|
10
|
+
return (
|
|
11
|
+
path.endsWith('.module.css') ||
|
|
12
|
+
(isExposeSharedDependencies && path.endsWith('design-system.css'))
|
|
13
|
+
);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const result: RuleSetRule[] = [
|
|
17
|
+
{
|
|
18
|
+
test: /\.module.css$/,
|
|
19
|
+
use: [styleLoader(context, { esModule: true }), cssLoader(context, { esModule: true })],
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
test: /(\.css)$/,
|
|
23
|
+
exclude: isProduction ? /\.module.css$/ : excludeCallback,
|
|
24
|
+
use: [styleLoader(context), cssLoader(context)],
|
|
25
|
+
},
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
if (isExposeSharedDependencies && !isProduction) {
|
|
29
|
+
result.push({
|
|
30
|
+
test: /design-system.css$/,
|
|
31
|
+
use: [MiniCssExtractPlugin.loader, cssLoader(context)],
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { RuleSetRule } from 'webpack';
|
|
2
|
+
import { Context } from '../types';
|
|
3
|
+
|
|
4
|
+
export function fontRules(_: Context): RuleSetRule[] {
|
|
5
|
+
return [
|
|
6
|
+
{
|
|
7
|
+
test: /\.(woff|woff2|eot|ttf|otf)$/i,
|
|
8
|
+
type: 'asset/resource',
|
|
9
|
+
generator: {
|
|
10
|
+
filename: 'fonts/[contenthash][ext][query]',
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
];
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { RuleSetRule } from 'webpack';
|
|
2
|
+
import { Context } from '../types';
|
|
3
|
+
|
|
4
|
+
export function imageRules(_: Context): RuleSetRule[] {
|
|
5
|
+
return [
|
|
6
|
+
{
|
|
7
|
+
test: /\.(png|svg|jpg|jpeg|gif)$/i,
|
|
8
|
+
type: 'asset',
|
|
9
|
+
generator: {
|
|
10
|
+
filename: 'images/[contenthash][ext][query]',
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
];
|
|
14
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { RuleSetRule } from 'webpack';
|
|
2
|
+
import { Context } from '../types';
|
|
3
|
+
|
|
4
|
+
export function jsRules(_: Context): RuleSetRule[] {
|
|
5
|
+
return [
|
|
6
|
+
{
|
|
7
|
+
enforce: 'pre',
|
|
8
|
+
test: /\.js$/,
|
|
9
|
+
exclude: /node_modules/,
|
|
10
|
+
loader: 'source-map-loader',
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
test: /\.worker\.js$/,
|
|
14
|
+
use: { loader: 'worker-loader' },
|
|
15
|
+
},
|
|
16
|
+
];
|
|
17
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { RuleSetRule } from 'webpack';
|
|
2
|
+
import { cssLoader, lessLoader, styleLoader } from '../loaders';
|
|
3
|
+
import { Context } from '../types';
|
|
4
|
+
|
|
5
|
+
export function lessRules(context: Context): RuleSetRule[] {
|
|
6
|
+
return [
|
|
7
|
+
{
|
|
8
|
+
test: /\.module.less$/,
|
|
9
|
+
use: [
|
|
10
|
+
styleLoader(context, { esModule: true }),
|
|
11
|
+
cssLoader(context, { esModule: true }),
|
|
12
|
+
lessLoader(),
|
|
13
|
+
],
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
test: /(\.less)$/,
|
|
17
|
+
exclude: /\.module.less$/,
|
|
18
|
+
use: [styleLoader(context), cssLoader(context), lessLoader()],
|
|
19
|
+
},
|
|
20
|
+
];
|
|
21
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { RuleSetRule } from 'webpack';
|
|
2
|
+
import { cssLoader, styleLoader } from '../loaders';
|
|
3
|
+
import { Context } from '../types';
|
|
4
|
+
|
|
5
|
+
export function scssRules(context: Context): RuleSetRule[] {
|
|
6
|
+
return [
|
|
7
|
+
{
|
|
8
|
+
test: /\.module.scss$/,
|
|
9
|
+
use: [
|
|
10
|
+
styleLoader(context, { esModule: true }),
|
|
11
|
+
cssLoader(context, { esModule: true }),
|
|
12
|
+
'sass-loader',
|
|
13
|
+
],
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
test: /(\.scss)$/,
|
|
17
|
+
exclude: /\.module.scss$/,
|
|
18
|
+
use: [styleLoader(context), cssLoader(context), 'sass-loader'],
|
|
19
|
+
},
|
|
20
|
+
];
|
|
21
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { RuleSetRule } from 'webpack';
|
|
2
|
+
import { Context } from '../types';
|
|
3
|
+
|
|
4
|
+
export function tsxRules({ esbuild }: Context): RuleSetRule[] {
|
|
5
|
+
const loader = esbuild
|
|
6
|
+
? {
|
|
7
|
+
loader: 'esbuild-loader',
|
|
8
|
+
options: { loader: 'tsx', target: 'es2018' },
|
|
9
|
+
}
|
|
10
|
+
: {
|
|
11
|
+
loader: 'ts-loader',
|
|
12
|
+
options: { transpileOnly: true },
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return [
|
|
16
|
+
{
|
|
17
|
+
test: /\.tsx?$/,
|
|
18
|
+
exclude: /node_modules/,
|
|
19
|
+
use: [loader],
|
|
20
|
+
},
|
|
21
|
+
];
|
|
22
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Configuration, RuleSetRule } from 'webpack';
|
|
2
|
+
import { getModuleEntryPath } from '../utils';
|
|
3
|
+
import { cssRules, fontRules, imageRules, jsRules, lessRules, scssRules, tsxRules } from './rules';
|
|
4
|
+
import { Context, Overrides } from './types';
|
|
5
|
+
|
|
6
|
+
type Config = NonNullable<Configuration['module']>['rules'];
|
|
7
|
+
interface Result {
|
|
8
|
+
rules: Config;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function rulesConfig(context: Context, _: Overrides): Result {
|
|
12
|
+
const rules: Config = [
|
|
13
|
+
jsRules,
|
|
14
|
+
imageRules,
|
|
15
|
+
fontRules,
|
|
16
|
+
tsxRules,
|
|
17
|
+
sharedDependenciesRules,
|
|
18
|
+
].flatMap(fn => fn(context));
|
|
19
|
+
|
|
20
|
+
if (!context.isCustomStyleRules) {
|
|
21
|
+
rules.push(...[scssRules, lessRules, cssRules].flatMap(fn => fn(context)));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return { rules };
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function sharedDependenciesRules(context: Context): RuleSetRule[] {
|
|
28
|
+
const { isExposeSharedDependencies, sharedDependencies } = context;
|
|
29
|
+
if (!isExposeSharedDependencies) {
|
|
30
|
+
return [];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return Object.entries(sharedDependencies).map(([dependency, variable]) => ({
|
|
34
|
+
test: getModuleEntryPath(dependency),
|
|
35
|
+
loader: require.resolve('../loaders/expose-loader'),
|
|
36
|
+
options: { exposes: variable },
|
|
37
|
+
}));
|
|
38
|
+
}
|