@nizza/devkit 0.1.0-alpha.1 → 0.1.0-alpha.3
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/cjs/executors/deploy/helpers.d.ts +4 -0
- package/dist/cjs/executors/deploy/helpers.js +26 -0
- package/dist/cjs/executors/deploy/index.d.ts +11 -0
- package/dist/cjs/executors/deploy/index.js +22 -0
- package/dist/{src → cjs}/executors/environments/helpers.d.ts +4 -4
- package/dist/cjs/executors/environments/helpers.js +63 -0
- package/dist/{src/executors/environments/executor.d.ts → cjs/executors/environments/index.d.ts} +5 -5
- package/dist/cjs/executors/environments/index.js +54 -0
- package/dist/{src → cjs}/executors/publish/helpers.d.ts +3 -3
- package/dist/cjs/executors/publish/helpers.js +51 -0
- package/dist/cjs/executors/publish/index.d.ts +12 -0
- package/dist/cjs/executors/publish/index.js +53 -0
- package/dist/cjs/executors/shared/utils.d.ts +34 -0
- package/dist/cjs/executors/shared/utils.js +78 -0
- package/dist/{src → cjs}/executors/update-executors-file/helpers.d.ts +7 -6
- package/dist/cjs/executors/update-executors-file/helpers.js +76 -0
- package/dist/{src/executors/update-executors-file/executor.d.ts → cjs/executors/update-executors-file/index.d.ts} +5 -5
- package/dist/cjs/executors/update-executors-file/index.js +41 -0
- package/dist/cjs/executors/vtex-link/constants.d.ts +4 -0
- package/dist/cjs/executors/vtex-link/constants.js +9 -0
- package/dist/{src → cjs}/executors/vtex-link/helpers.d.ts +15 -15
- package/dist/cjs/executors/vtex-link/helpers.js +206 -0
- package/dist/cjs/executors/vtex-link/index.d.ts +5 -0
- package/dist/cjs/executors/vtex-link/index.js +30 -0
- package/dist/cjs/index-0ce2daf7.d.ts +2 -0
- package/dist/cjs/index-17143e35.d.ts +2 -0
- package/dist/cjs/index-3080371d.d.ts +3 -0
- package/dist/cjs/index-f6330edc.d.ts +2 -0
- package/dist/cjs/index.d.ts +10 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +59 -0
- package/dist/cjs/scripts/changeset-pre-mode.d.ts +2 -0
- package/dist/cjs/scripts/changeset-pre-mode.js +41 -0
- package/dist/{src → cjs/shared}/logger.d.ts +5 -6
- package/dist/cjs/shared/logger.js +98 -0
- package/dist/{src → cjs}/shared/utils.d.ts +2 -2
- package/dist/cjs/shared/utils.js +25 -0
- package/dist/{src/executors/vtex-link/types.d.ts → cjs/types-1282e639.d.ts} +3 -3
- package/dist/cjs/types-7377dcc9.d.ts +4 -0
- package/dist/cjs/types-763439e4.d.ts +14 -0
- package/dist/cjs/vite/config-builder/configs/app.d.ts +4 -0
- package/dist/cjs/vite/config-builder/configs/app.js +13 -0
- package/dist/cjs/vite/config-builder/configs/base.d.ts +4 -0
- package/dist/cjs/vite/config-builder/configs/base.js +57 -0
- package/dist/cjs/vite/config-builder/configs/index.d.ts +7 -0
- package/dist/cjs/vite/config-builder/configs/index.js +36 -0
- package/dist/cjs/vite/config-builder/configs/lib.d.ts +4 -0
- package/dist/cjs/vite/config-builder/configs/lib.js +57 -0
- package/dist/cjs/vite/config-builder/configs/script.d.ts +4 -0
- package/dist/cjs/vite/config-builder/configs/script.js +45 -0
- package/dist/cjs/vite/config-builder/main.d.ts +10 -0
- package/dist/cjs/vite/config-builder/main.js +43 -0
- package/dist/{src → cjs}/vite/config-builder/plugins.d.ts +7 -7
- package/dist/cjs/vite/config-builder/plugins.js +95 -0
- package/dist/{src → cjs}/vite/config-builder/shared/types.d.ts +17 -17
- package/dist/cjs/vite/config-builder/shared/types.js +33 -0
- package/dist/{src → cjs}/vite/config-builder/shared/utils/helpers.d.ts +10 -10
- package/dist/cjs/vite/config-builder/shared/utils/helpers.js +124 -0
- package/dist/{src → cjs}/vite/config-builder/shared/utils/projectConfig.d.ts +8 -8
- package/dist/cjs/vite/config-builder/shared/utils/projectConfig.js +114 -0
- package/dist/{src → cjs}/vite/config-builder/shared/utils/viteCommand.d.ts +4 -4
- package/dist/cjs/vite/config-builder/shared/utils/viteCommand.js +59 -0
- package/dist/cjs/vite/plugins/shadow-dom-inject-css/index.d.ts +7 -0
- package/dist/{src → cjs}/vite/plugins/shadow-dom-inject-css/index.js +4 -19
- package/dist/cjs/vite/plugins/third-party-css-inject/main.d.ts +17 -0
- package/dist/{src → cjs}/vite/plugins/third-party-css-inject/main.js +13 -14
- package/dist/cjs/vite/plugins/third-party-css-inject/utils.d.ts +5 -0
- package/dist/{src → cjs}/vite/plugins/third-party-css-inject/utils.js +8 -20
- package/dist/esm/executors/deploy/helpers.d.ts +4 -0
- package/dist/esm/executors/deploy/helpers.js +22 -0
- package/dist/esm/executors/deploy/index.d.ts +11 -0
- package/dist/esm/executors/deploy/index.js +20 -0
- package/dist/esm/executors/deploy/schema.json +41 -0
- package/dist/esm/executors/environments/helpers.d.ts +21 -0
- package/dist/esm/executors/environments/helpers.js +59 -0
- package/dist/esm/executors/environments/index.d.ts +16 -0
- package/dist/{src/executors/environments/executor.js → esm/executors/environments/index.js} +23 -30
- package/dist/esm/executors/environments/schema.json +9 -0
- package/dist/esm/executors/publish/helpers.d.ts +19 -0
- package/dist/esm/executors/publish/helpers.js +48 -0
- package/dist/esm/executors/publish/index.d.ts +12 -0
- package/dist/esm/executors/publish/index.js +51 -0
- package/dist/esm/executors/publish/schema.json +19 -0
- package/dist/esm/executors/shared/utils.d.ts +34 -0
- package/dist/esm/executors/shared/utils.js +72 -0
- package/dist/esm/executors/update-executors-file/helpers.d.ts +25 -0
- package/dist/esm/executors/update-executors-file/helpers.js +71 -0
- package/dist/esm/executors/update-executors-file/index.d.ts +12 -0
- package/dist/esm/executors/update-executors-file/index.js +39 -0
- package/dist/esm/executors/update-executors-file/schema.json +9 -0
- package/dist/esm/executors/vtex-link/constants.d.ts +4 -0
- package/dist/esm/executors/vtex-link/constants.js +5 -0
- package/dist/esm/executors/vtex-link/helpers.d.ts +77 -0
- package/dist/esm/executors/vtex-link/helpers.js +192 -0
- package/dist/esm/executors/vtex-link/index.d.ts +5 -0
- package/dist/esm/executors/vtex-link/index.js +28 -0
- package/dist/esm/executors/vtex-link/schema.json +25 -0
- package/dist/esm/index-0ce2daf7.d.ts +2 -0
- package/dist/esm/index-17143e35.d.ts +2 -0
- package/dist/esm/index-3080371d.d.ts +3 -0
- package/dist/esm/index-f6330edc.d.ts +2 -0
- package/dist/esm/index.d.ts +10 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +13 -0
- package/dist/esm/scripts/changeset-pre-mode.d.ts +2 -0
- package/dist/esm/scripts/changeset-pre-mode.js +39 -0
- package/dist/esm/shared/logger.d.ts +33 -0
- package/dist/{src → esm/shared}/logger.js +28 -39
- package/dist/esm/shared/utils.d.ts +11 -0
- package/dist/esm/shared/utils.js +23 -0
- package/dist/esm/types-1282e639.d.ts +12 -0
- package/dist/esm/types-7377dcc9.d.ts +4 -0
- package/dist/esm/types-763439e4.d.ts +14 -0
- package/dist/esm/vite/config-builder/configs/app.d.ts +4 -0
- package/dist/esm/vite/config-builder/configs/app.js +11 -0
- package/dist/esm/vite/config-builder/configs/base.d.ts +4 -0
- package/dist/{src → esm}/vite/config-builder/configs/base.js +22 -22
- package/dist/esm/vite/config-builder/configs/index.d.ts +7 -0
- package/dist/esm/vite/config-builder/configs/index.js +30 -0
- package/dist/esm/vite/config-builder/configs/lib.d.ts +4 -0
- package/dist/{src → esm}/vite/config-builder/configs/lib.js +16 -18
- package/dist/esm/vite/config-builder/configs/script.d.ts +4 -0
- package/dist/esm/vite/config-builder/configs/script.js +43 -0
- package/dist/esm/vite/config-builder/main.d.ts +10 -0
- package/dist/esm/vite/config-builder/main.js +41 -0
- package/dist/esm/vite/config-builder/plugins.d.ts +30 -0
- package/dist/esm/vite/config-builder/plugins.js +89 -0
- package/dist/esm/vite/config-builder/shared/types.d.ts +155 -0
- package/dist/{src → esm}/vite/config-builder/shared/types.js +2 -27
- package/dist/esm/vite/config-builder/shared/utils/helpers.d.ts +81 -0
- package/dist/esm/vite/config-builder/shared/utils/helpers.js +98 -0
- package/dist/esm/vite/config-builder/shared/utils/projectConfig.d.ts +60 -0
- package/dist/esm/vite/config-builder/shared/utils/projectConfig.js +109 -0
- package/dist/esm/vite/config-builder/shared/utils/viteCommand.d.ts +24 -0
- package/dist/esm/vite/config-builder/shared/utils/viteCommand.js +56 -0
- package/dist/esm/vite/plugins/shadow-dom-inject-css/index.d.ts +7 -0
- package/dist/esm/vite/plugins/shadow-dom-inject-css/index.js +27 -0
- package/dist/esm/vite/plugins/third-party-css-inject/main.d.ts +17 -0
- package/dist/esm/vite/plugins/third-party-css-inject/main.js +45 -0
- package/dist/esm/vite/plugins/third-party-css-inject/utils.d.ts +5 -0
- package/dist/esm/vite/plugins/third-party-css-inject/utils.js +97 -0
- package/dist/executors.json +29 -0
- package/package.json +36 -5
- package/dist/package.json +0 -13
- package/dist/src/executors/deploy/executor.d.ts +0 -11
- package/dist/src/executors/deploy/executor.d.ts.map +0 -1
- package/dist/src/executors/deploy/executor.js +0 -27
- package/dist/src/executors/deploy/helpers.d.ts +0 -4
- package/dist/src/executors/deploy/helpers.d.ts.map +0 -1
- package/dist/src/executors/deploy/helpers.js +0 -40
- package/dist/src/executors/environments/executor.d.ts.map +0 -1
- package/dist/src/executors/environments/helpers.d.ts.map +0 -1
- package/dist/src/executors/environments/helpers.js +0 -63
- package/dist/src/executors/publish/executor.d.ts +0 -12
- package/dist/src/executors/publish/executor.d.ts.map +0 -1
- package/dist/src/executors/publish/executor.js +0 -58
- package/dist/src/executors/publish/helpers.d.ts.map +0 -1
- package/dist/src/executors/publish/helpers.js +0 -52
- package/dist/src/executors/shared/index.d.ts +0 -3
- package/dist/src/executors/shared/index.d.ts.map +0 -1
- package/dist/src/executors/shared/index.js +0 -7
- package/dist/src/executors/shared/types.d.ts +0 -4
- package/dist/src/executors/shared/types.d.ts.map +0 -1
- package/dist/src/executors/shared/types.js +0 -4
- package/dist/src/executors/shared/utils.d.ts +0 -34
- package/dist/src/executors/shared/utils.d.ts.map +0 -1
- package/dist/src/executors/shared/utils.js +0 -74
- package/dist/src/executors/update-executors-file/executor.d.ts.map +0 -1
- package/dist/src/executors/update-executors-file/executor.js +0 -46
- package/dist/src/executors/update-executors-file/helpers.d.ts.map +0 -1
- package/dist/src/executors/update-executors-file/helpers.js +0 -70
- package/dist/src/executors/update-executors-file/types.d.ts +0 -14
- package/dist/src/executors/update-executors-file/types.d.ts.map +0 -1
- package/dist/src/executors/update-executors-file/types.js +0 -4
- package/dist/src/executors/vtex-link/constants.d.ts +0 -4
- package/dist/src/executors/vtex-link/constants.d.ts.map +0 -1
- package/dist/src/executors/vtex-link/constants.js +0 -24
- package/dist/src/executors/vtex-link/executor.d.ts +0 -5
- package/dist/src/executors/vtex-link/executor.d.ts.map +0 -1
- package/dist/src/executors/vtex-link/executor.js +0 -35
- package/dist/src/executors/vtex-link/helpers.d.ts.map +0 -1
- package/dist/src/executors/vtex-link/helpers.js +0 -187
- package/dist/src/executors/vtex-link/types.d.ts.map +0 -1
- package/dist/src/executors/vtex-link/types.js +0 -4
- package/dist/src/index.d.ts +0 -2
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/index.js +0 -6
- package/dist/src/logger.d.ts.map +0 -1
- package/dist/src/scripts/changeset-pre-mode.d.ts +0 -2
- package/dist/src/scripts/changeset-pre-mode.d.ts.map +0 -1
- package/dist/src/scripts/changeset-pre-mode.js +0 -41
- package/dist/src/shared/index.d.ts +0 -2
- package/dist/src/shared/index.d.ts.map +0 -1
- package/dist/src/shared/index.js +0 -6
- package/dist/src/shared/utils.d.ts.map +0 -1
- package/dist/src/shared/utils.js +0 -22
- package/dist/src/vite/config-builder/configs/app.d.ts +0 -4
- package/dist/src/vite/config-builder/configs/app.d.ts.map +0 -1
- package/dist/src/vite/config-builder/configs/app.js +0 -19
- package/dist/src/vite/config-builder/configs/base.d.ts +0 -4
- package/dist/src/vite/config-builder/configs/base.d.ts.map +0 -1
- package/dist/src/vite/config-builder/configs/index.d.ts +0 -7
- package/dist/src/vite/config-builder/configs/index.d.ts.map +0 -1
- package/dist/src/vite/config-builder/configs/index.js +0 -28
- package/dist/src/vite/config-builder/configs/lib.d.ts +0 -4
- package/dist/src/vite/config-builder/configs/lib.d.ts.map +0 -1
- package/dist/src/vite/config-builder/configs/script.d.ts +0 -4
- package/dist/src/vite/config-builder/configs/script.d.ts.map +0 -1
- package/dist/src/vite/config-builder/configs/script.js +0 -42
- package/dist/src/vite/config-builder/index.d.ts +0 -3
- package/dist/src/vite/config-builder/index.d.ts.map +0 -1
- package/dist/src/vite/config-builder/index.js +0 -7
- package/dist/src/vite/config-builder/main.d.ts +0 -10
- package/dist/src/vite/config-builder/main.d.ts.map +0 -1
- package/dist/src/vite/config-builder/main.js +0 -37
- package/dist/src/vite/config-builder/plugins.d.ts.map +0 -1
- package/dist/src/vite/config-builder/plugins.js +0 -88
- package/dist/src/vite/config-builder/shared/index.d.ts +0 -3
- package/dist/src/vite/config-builder/shared/index.d.ts.map +0 -1
- package/dist/src/vite/config-builder/shared/index.js +0 -7
- package/dist/src/vite/config-builder/shared/types.d.ts.map +0 -1
- package/dist/src/vite/config-builder/shared/utils/helpers.d.ts.map +0 -1
- package/dist/src/vite/config-builder/shared/utils/helpers.js +0 -61
- package/dist/src/vite/config-builder/shared/utils/index.d.ts +0 -4
- package/dist/src/vite/config-builder/shared/utils/index.d.ts.map +0 -1
- package/dist/src/vite/config-builder/shared/utils/index.js +0 -8
- package/dist/src/vite/config-builder/shared/utils/projectConfig.d.ts.map +0 -1
- package/dist/src/vite/config-builder/shared/utils/projectConfig.js +0 -85
- package/dist/src/vite/config-builder/shared/utils/viteCommand.d.ts.map +0 -1
- package/dist/src/vite/config-builder/shared/utils/viteCommand.js +0 -54
- package/dist/src/vite/index.d.ts +0 -3
- package/dist/src/vite/index.d.ts.map +0 -1
- package/dist/src/vite/index.js +0 -7
- package/dist/src/vite/plugins/index.d.ts +0 -3
- package/dist/src/vite/plugins/index.d.ts.map +0 -1
- package/dist/src/vite/plugins/index.js +0 -7
- package/dist/src/vite/plugins/shadow-dom-inject-css/index.d.ts +0 -8
- package/dist/src/vite/plugins/shadow-dom-inject-css/index.d.ts.map +0 -1
- package/dist/src/vite/plugins/third-party-css-inject/index.d.ts +0 -4
- package/dist/src/vite/plugins/third-party-css-inject/index.d.ts.map +0 -1
- package/dist/src/vite/plugins/third-party-css-inject/index.js +0 -13
- package/dist/src/vite/plugins/third-party-css-inject/main.d.ts +0 -17
- package/dist/src/vite/plugins/third-party-css-inject/main.d.ts.map +0 -1
- package/dist/src/vite/plugins/third-party-css-inject/utils.d.ts +0 -5
- package/dist/src/vite/plugins/third-party-css-inject/utils.d.ts.map +0 -1
- /package/dist/{src → cjs}/executors/deploy/schema.json +0 -0
- /package/dist/{src → cjs}/executors/environments/schema.json +0 -0
- /package/dist/{src → cjs}/executors/publish/schema.json +0 -0
- /package/dist/{src → cjs}/executors/update-executors-file/schema.json +0 -0
- /package/dist/{src → cjs}/executors/vtex-link/schema.json +0 -0
|
@@ -1,40 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const _fs = require("fs");
|
|
14
|
-
const _path = require("path");
|
|
1
|
+
import { bundleAnalysisPlugin, basePlugins } from '../plugins.js';
|
|
2
|
+
import { Target, ViteMode, Flag, Stage } from '../shared/types.js';
|
|
3
|
+
import { getPlugins, when } from '../shared/utils/helpers.js';
|
|
4
|
+
import 'minimatch';
|
|
5
|
+
import '../../../shared/logger.js';
|
|
6
|
+
import '@nx/devkit';
|
|
7
|
+
import { existsSync } from 'fs';
|
|
8
|
+
import { resolve } from 'path';
|
|
9
|
+
import 'chalk';
|
|
10
|
+
import 'mri';
|
|
11
|
+
import 'vite';
|
|
12
|
+
|
|
15
13
|
const getBaseConfig = (ctx)=>{
|
|
16
14
|
const { commonConfig, projectConfig, viteCmd } = ctx;
|
|
17
15
|
const { resolveEnvs, path } = projectConfig;
|
|
18
16
|
const { stage, target, flags: cmdOverrides } = viteCmd;
|
|
19
|
-
const NODE_ENV = target ===
|
|
20
|
-
const sourcemap = cmdOverrides?.[
|
|
17
|
+
const NODE_ENV = target === Target.BUILD ? ViteMode.PROD : ViteMode.DEV;
|
|
18
|
+
const sourcemap = cmdOverrides?.[Flag.SOURCEMAP] ?? stage !== Stage.PROD;
|
|
21
19
|
const envPrefix = `${commonConfig.envPrefix.toUpperCase()}_`;
|
|
22
20
|
const omittedStages = resolveEnvs.local ? [
|
|
23
|
-
|
|
21
|
+
Stage.DEV
|
|
24
22
|
] : [
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
Stage.DEV,
|
|
24
|
+
Stage.LOCAL
|
|
27
25
|
];
|
|
28
26
|
const envPath = `environments/environment.${stage}.ts`;
|
|
29
27
|
const fallbackEnvPath = `environments/environment.ts`;
|
|
30
28
|
// Verify if the local Environment file is present
|
|
31
|
-
const envFilePath =
|
|
29
|
+
const envFilePath = existsSync(resolve(path, 'src', envPath)) ? envPath : fallbackEnvPath;
|
|
32
30
|
return {
|
|
33
31
|
envPrefix,
|
|
34
|
-
plugins:
|
|
32
|
+
plugins: getPlugins(ctx, basePlugins, bundleAnalysisPlugin),
|
|
35
33
|
resolve: {
|
|
36
34
|
alias: {
|
|
37
|
-
...
|
|
35
|
+
...when(resolveEnvs.default && !omittedStages.includes(stage), {
|
|
38
36
|
'~env': envFilePath
|
|
39
37
|
})
|
|
40
38
|
}
|
|
@@ -53,3 +51,5 @@ const getBaseConfig = (ctx)=>{
|
|
|
53
51
|
}
|
|
54
52
|
};
|
|
55
53
|
};
|
|
54
|
+
|
|
55
|
+
export { getBaseConfig };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ProjectType, Context } from "../../../index-f6330edc.js";
|
|
2
|
+
declare const getConfig: (ctx: Context, type?: ProjectType | null) => import("vite").UserConfig;
|
|
3
|
+
export * from "./app.js";
|
|
4
|
+
export * from "./base.js";
|
|
5
|
+
export * from "./lib.js";
|
|
6
|
+
export * from "./script.js";
|
|
7
|
+
export { getConfig };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ProjectType } from '../shared/types.js';
|
|
2
|
+
import '@nx/devkit';
|
|
3
|
+
import 'nanoid';
|
|
4
|
+
import 'path';
|
|
5
|
+
import 'ramda';
|
|
6
|
+
import 'minimatch';
|
|
7
|
+
import '../../../shared/logger.js';
|
|
8
|
+
import 'fs';
|
|
9
|
+
import 'chalk';
|
|
10
|
+
import 'mri';
|
|
11
|
+
import 'vite';
|
|
12
|
+
import { getAppConfig } from './app.js';
|
|
13
|
+
import { getBaseConfig } from './base.js';
|
|
14
|
+
import { getLibConfig } from './lib.js';
|
|
15
|
+
import { getScriptConfig } from './script.js';
|
|
16
|
+
|
|
17
|
+
const getConfig = (ctx, type = null)=>{
|
|
18
|
+
switch(type){
|
|
19
|
+
case ProjectType.APP:
|
|
20
|
+
return getAppConfig(ctx);
|
|
21
|
+
case ProjectType.LIB:
|
|
22
|
+
return getLibConfig(ctx);
|
|
23
|
+
case ProjectType.SCRIPT:
|
|
24
|
+
return getScriptConfig(ctx);
|
|
25
|
+
default:
|
|
26
|
+
return getBaseConfig(ctx);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export { getAppConfig, getBaseConfig, getConfig, getLibConfig, getScriptConfig };
|
|
@@ -1,34 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
});
|
|
11
|
-
const _path = require("path");
|
|
12
|
-
const _plugins = require("../plugins");
|
|
13
|
-
const _shared = require("../shared");
|
|
1
|
+
import { resolve } from 'path';
|
|
2
|
+
import { dtsPlugin } from '../plugins.js';
|
|
3
|
+
import '../shared/types.js';
|
|
4
|
+
import { when, getPlugins } from '../shared/utils/helpers.js';
|
|
5
|
+
import { getExternalDependencies } from '../shared/utils/projectConfig.js';
|
|
6
|
+
import 'chalk';
|
|
7
|
+
import 'mri';
|
|
8
|
+
import 'vite';
|
|
9
|
+
|
|
14
10
|
const getLibConfig = (ctx)=>{
|
|
15
11
|
const { projectConfig, commonConfig } = ctx;
|
|
16
12
|
const { externalizeLibGlob = [] } = commonConfig;
|
|
17
13
|
const { name, path, externalizeLibs } = projectConfig;
|
|
18
|
-
const entry =
|
|
14
|
+
const entry = resolve(path, projectConfig.entry ?? 'src/index.ts');
|
|
19
15
|
const defaultExternals = {
|
|
20
16
|
react: true,
|
|
21
17
|
'react-dom': true,
|
|
22
18
|
'react/jsx-runtime': true
|
|
23
19
|
};
|
|
24
20
|
// Get external dependencies based on glob patterns
|
|
25
|
-
const externalDeps =
|
|
21
|
+
const externalDeps = getExternalDependencies(path, [
|
|
26
22
|
...externalizeLibGlob,
|
|
27
23
|
...externalizeLibs.glob
|
|
28
24
|
]);
|
|
29
25
|
const rollupExternal = [
|
|
30
26
|
...externalDeps,
|
|
31
|
-
...Object.keys(
|
|
27
|
+
...Object.keys(when(externalizeLibs.default, defaultExternals))
|
|
32
28
|
];
|
|
33
29
|
const rollupGlobals = {
|
|
34
30
|
react: 'React',
|
|
@@ -36,7 +32,7 @@ const getLibConfig = (ctx)=>{
|
|
|
36
32
|
'react/jsx-runtime': 'ReactJsxRuntime'
|
|
37
33
|
};
|
|
38
34
|
return {
|
|
39
|
-
plugins:
|
|
35
|
+
plugins: getPlugins(ctx, dtsPlugin),
|
|
40
36
|
build: {
|
|
41
37
|
lib: {
|
|
42
38
|
name,
|
|
@@ -49,9 +45,11 @@ const getLibConfig = (ctx)=>{
|
|
|
49
45
|
rollupOptions: {
|
|
50
46
|
external: rollupExternal,
|
|
51
47
|
output: {
|
|
52
|
-
globals:
|
|
48
|
+
globals: when(externalizeLibs.default, rollupGlobals)
|
|
53
49
|
}
|
|
54
50
|
}
|
|
55
51
|
}
|
|
56
52
|
};
|
|
57
53
|
};
|
|
54
|
+
|
|
55
|
+
export { getLibConfig };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { resolve } from 'path';
|
|
2
|
+
import { injectCssByJsPlugin, injectCssIntoShadowDomPlugin } from '../plugins.js';
|
|
3
|
+
import '../shared/types.js';
|
|
4
|
+
import { getPlugins, chunkName } from '../shared/utils/helpers.js';
|
|
5
|
+
import 'minimatch';
|
|
6
|
+
import '../../../shared/logger.js';
|
|
7
|
+
import '@nx/devkit';
|
|
8
|
+
import 'fs';
|
|
9
|
+
import 'chalk';
|
|
10
|
+
import 'mri';
|
|
11
|
+
import 'vite';
|
|
12
|
+
|
|
13
|
+
const getScriptConfig = (ctx)=>{
|
|
14
|
+
const { commonConfig, projectConfig } = ctx;
|
|
15
|
+
const { envPrefix } = commonConfig;
|
|
16
|
+
const { port } = projectConfig;
|
|
17
|
+
const { name, path, fileName, chunkPrefix } = projectConfig;
|
|
18
|
+
const entry = resolve(path, projectConfig.entry ?? 'src/main');
|
|
19
|
+
return {
|
|
20
|
+
plugins: getPlugins(ctx, injectCssIntoShadowDomPlugin, injectCssByJsPlugin),
|
|
21
|
+
server: {
|
|
22
|
+
port,
|
|
23
|
+
host: true
|
|
24
|
+
},
|
|
25
|
+
build: {
|
|
26
|
+
lib: {
|
|
27
|
+
name,
|
|
28
|
+
entry,
|
|
29
|
+
fileName,
|
|
30
|
+
formats: [
|
|
31
|
+
'es'
|
|
32
|
+
]
|
|
33
|
+
},
|
|
34
|
+
rollupOptions: {
|
|
35
|
+
output: {
|
|
36
|
+
chunkFileNames: chunkName(`${envPrefix}-${chunkPrefix}`)
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export { getScriptConfig };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { UserConfig } from 'vite';
|
|
2
|
+
import { CommonProjectConfig, ProjectConfig } from "../../index-f6330edc.js";
|
|
3
|
+
/**
|
|
4
|
+
* Builds the configuration based on common and project-specific configurations.
|
|
5
|
+
*
|
|
6
|
+
* @param {CommonProjectConfig} commonConfig - The common configuration.
|
|
7
|
+
* @returns - Returns a function that accepts a project configuration and returns the Vite configuration.
|
|
8
|
+
*/
|
|
9
|
+
declare const createConfigBuilder: (commonConfig: CommonProjectConfig) => (projectConfig: ProjectConfig) => UserConfig;
|
|
10
|
+
export { createConfigBuilder };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { defineConfig } from 'vite';
|
|
2
|
+
import { currentLogLevel, LogLevel, logger } from '../../shared/logger.js';
|
|
3
|
+
import { getPkgJson } from '../../shared/utils.js';
|
|
4
|
+
import { getConfig } from './configs/index.js';
|
|
5
|
+
import './shared/types.js';
|
|
6
|
+
import '@nx/devkit';
|
|
7
|
+
import 'nanoid';
|
|
8
|
+
import 'path';
|
|
9
|
+
import 'ramda';
|
|
10
|
+
import { initializeConfig, mergeConfigs } from './shared/utils/projectConfig.js';
|
|
11
|
+
import 'chalk';
|
|
12
|
+
import 'mri';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Builds the configuration based on common and project-specific configurations.
|
|
16
|
+
*
|
|
17
|
+
* @param {CommonProjectConfig} commonConfig - The common configuration.
|
|
18
|
+
* @returns - Returns a function that accepts a project configuration and returns the Vite configuration.
|
|
19
|
+
*/ const createConfigBuilder = (commonConfig)=>(projectConfig)=>{
|
|
20
|
+
try {
|
|
21
|
+
const localPkgJson = getPkgJson(projectConfig.path);
|
|
22
|
+
const { cfg, viteCmd } = initializeConfig(commonConfig, projectConfig, localPkgJson);
|
|
23
|
+
const isDebug = currentLogLevel === LogLevel.DEBUG;
|
|
24
|
+
const { type, overrides } = cfg;
|
|
25
|
+
const ctx = {
|
|
26
|
+
viteCmd,
|
|
27
|
+
localPkgJson,
|
|
28
|
+
commonConfig,
|
|
29
|
+
projectConfig: cfg
|
|
30
|
+
};
|
|
31
|
+
const defaultConfig = mergeConfigs(getConfig(ctx), getConfig(ctx, type));
|
|
32
|
+
const config = mergeConfigs(defaultConfig, overrides);
|
|
33
|
+
if (isDebug) logger.debug('Generated config:', config);
|
|
34
|
+
return defineConfig(config);
|
|
35
|
+
} catch (err) {
|
|
36
|
+
logger.error('buildConfig unexpected error:');
|
|
37
|
+
throw err;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export { createConfigBuilder };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { PluginConfig } from "../../index-f6330edc.js";
|
|
2
|
+
/**
|
|
3
|
+
* Base plugins configuration for apps and libs.
|
|
4
|
+
*
|
|
5
|
+
* Plugins configured:
|
|
6
|
+
* - vite-tsconfig-paths
|
|
7
|
+
* - @originjs/vite-plugin-commonjs
|
|
8
|
+
* - @rollup/plugin-graphql
|
|
9
|
+
* - @vitejs/plugin-react-swc
|
|
10
|
+
*/
|
|
11
|
+
declare const basePlugins: PluginConfig;
|
|
12
|
+
/**
|
|
13
|
+
* Plugin configuration for generating type declarations using vite-plugin-dts.
|
|
14
|
+
*/
|
|
15
|
+
declare const dtsPlugin: PluginConfig;
|
|
16
|
+
/**
|
|
17
|
+
* Plugin configuration for bundle analysis using rollup-plugin-visualizer.
|
|
18
|
+
*/
|
|
19
|
+
declare const bundleAnalysisPlugin: PluginConfig;
|
|
20
|
+
/**
|
|
21
|
+
* Plugin configuration for injecting CSS into JS files
|
|
22
|
+
* using vite-plugin-css-injected-by-js.
|
|
23
|
+
*/
|
|
24
|
+
declare const injectCssByJsPlugin: PluginConfig;
|
|
25
|
+
/**
|
|
26
|
+
* Plugin configuration for injecting CSS into Shadow Dom.
|
|
27
|
+
* using local plugin.
|
|
28
|
+
*/
|
|
29
|
+
declare const injectCssIntoShadowDomPlugin: PluginConfig;
|
|
30
|
+
export { basePlugins, dtsPlugin, bundleAnalysisPlugin, injectCssByJsPlugin, injectCssIntoShadowDomPlugin };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { viteCommonjs } from '@originjs/vite-plugin-commonjs';
|
|
2
|
+
import graphql from '@rollup/plugin-graphql';
|
|
3
|
+
import react from '@vitejs/plugin-react-swc';
|
|
4
|
+
import { resolve } from 'path';
|
|
5
|
+
import { visualizer } from 'rollup-plugin-visualizer';
|
|
6
|
+
import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js';
|
|
7
|
+
import dts from 'vite-plugin-dts';
|
|
8
|
+
import tsconfigPaths from 'vite-tsconfig-paths';
|
|
9
|
+
import 'vite';
|
|
10
|
+
import { injectCssIntoShadowDom } from '../plugins/shadow-dom-inject-css/index.js';
|
|
11
|
+
import { Stage, Flag } from './shared/types.js';
|
|
12
|
+
import { getNxTsConfigPaths } from './shared/utils/helpers.js';
|
|
13
|
+
import 'minimatch';
|
|
14
|
+
import '../../shared/logger.js';
|
|
15
|
+
import '@nx/devkit';
|
|
16
|
+
import 'fs';
|
|
17
|
+
import 'chalk';
|
|
18
|
+
import 'mri';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Base plugins configuration for apps and libs.
|
|
22
|
+
*
|
|
23
|
+
* Plugins configured:
|
|
24
|
+
* - vite-tsconfig-paths
|
|
25
|
+
* - @originjs/vite-plugin-commonjs
|
|
26
|
+
* - @rollup/plugin-graphql
|
|
27
|
+
* - @vitejs/plugin-react-swc
|
|
28
|
+
*/ const basePlugins = {
|
|
29
|
+
generate: ({ projectConfig })=>{
|
|
30
|
+
const projects = getNxTsConfigPaths();
|
|
31
|
+
return [
|
|
32
|
+
// tsconfigPaths({
|
|
33
|
+
// projects: tsConfigPaths.map(x => resolve(process.cwd(), x)),
|
|
34
|
+
// }),
|
|
35
|
+
tsconfigPaths({
|
|
36
|
+
projects
|
|
37
|
+
}),
|
|
38
|
+
viteCommonjs(),
|
|
39
|
+
graphql(),
|
|
40
|
+
react({
|
|
41
|
+
tsDecorators: true
|
|
42
|
+
})
|
|
43
|
+
];
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Plugin configuration for generating type declarations using vite-plugin-dts.
|
|
48
|
+
*/ const dtsPlugin = {
|
|
49
|
+
generate: ({ projectConfig })=>[
|
|
50
|
+
dts({
|
|
51
|
+
tsconfigPath: resolve(projectConfig.path, 'tsconfig.lib.json'),
|
|
52
|
+
outDir: resolve(projectConfig.path, 'dist'),
|
|
53
|
+
entryRoot: resolve(projectConfig.path, 'src')
|
|
54
|
+
})
|
|
55
|
+
],
|
|
56
|
+
condition: ({ projectConfig, viteCmd })=>viteCmd.stage !== Stage.LOCAL && projectConfig.dts == null ? true : !!projectConfig.dts
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Plugin configuration for bundle analysis using rollup-plugin-visualizer.
|
|
60
|
+
*/ const bundleAnalysisPlugin = {
|
|
61
|
+
generate: ({ projectConfig })=>[
|
|
62
|
+
visualizer({
|
|
63
|
+
emitFile: true,
|
|
64
|
+
projectRoot: resolve(projectConfig.path, 'dist'),
|
|
65
|
+
filename: 'bundle-analysis.html'
|
|
66
|
+
})
|
|
67
|
+
],
|
|
68
|
+
condition: ({ viteCmd })=>viteCmd.flags?.[Flag.ANALYZE] === 'true'
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Plugin configuration for injecting CSS into JS files
|
|
72
|
+
* using vite-plugin-css-injected-by-js.
|
|
73
|
+
*/ const injectCssByJsPlugin = {
|
|
74
|
+
generate: (_)=>[
|
|
75
|
+
cssInjectedByJsPlugin()
|
|
76
|
+
],
|
|
77
|
+
condition: ({ projectConfig })=>!projectConfig.shadowDom
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Plugin configuration for injecting CSS into Shadow Dom.
|
|
81
|
+
* using local plugin.
|
|
82
|
+
*/ const injectCssIntoShadowDomPlugin = {
|
|
83
|
+
generate: (_)=>[
|
|
84
|
+
injectCssIntoShadowDom()
|
|
85
|
+
],
|
|
86
|
+
condition: ({ projectConfig })=>projectConfig.shadowDom
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export { basePlugins, bundleAnalysisPlugin, dtsPlugin, injectCssByJsPlugin, injectCssIntoShadowDomPlugin };
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { ConfigEnv, LibraryOptions, UserConfig } from 'vite';
|
|
2
|
+
import { LogLevel } from "../../../index-17143e35.js";
|
|
3
|
+
declare enum ViteMode {
|
|
4
|
+
PROD = "production",
|
|
5
|
+
DEV = "development"
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Project stages, it coincides with the target configurations of the project.json of NX.
|
|
9
|
+
* @readonly
|
|
10
|
+
* @enum {string}
|
|
11
|
+
*/
|
|
12
|
+
declare enum Stage {
|
|
13
|
+
PROD = "prod",
|
|
14
|
+
DEV = "dev",
|
|
15
|
+
STAGING = "staging",
|
|
16
|
+
LOCAL = "local"
|
|
17
|
+
}
|
|
18
|
+
declare enum ProjectType {
|
|
19
|
+
APP = "app",
|
|
20
|
+
LIB = "lib",
|
|
21
|
+
SCRIPT = "script"
|
|
22
|
+
}
|
|
23
|
+
declare enum Flag {
|
|
24
|
+
SOURCEMAP = "source-maps",
|
|
25
|
+
ANALYZE = "analyze",
|
|
26
|
+
VERBOSE = "verbose",
|
|
27
|
+
VERBOSE_ALIAS = "v"
|
|
28
|
+
}
|
|
29
|
+
declare enum Target {
|
|
30
|
+
BUILD = "build",
|
|
31
|
+
PREVIEW = "preview",
|
|
32
|
+
SERVE = "serve"
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Vite Environment.
|
|
36
|
+
*
|
|
37
|
+
* @property {ViteMode} mode - Vite mode.
|
|
38
|
+
*/
|
|
39
|
+
type ViteEnv = ConfigEnv & {
|
|
40
|
+
mode: ViteMode;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Externalizing libraries.
|
|
44
|
+
*
|
|
45
|
+
* @property {boolean} default - React externalizes and other common dependencies,
|
|
46
|
+
* this only applies to libraries.
|
|
47
|
+
* @property {boolean} glob - Glob expression or list of glob expressions to exclude
|
|
48
|
+
* dependencies from the package.json.
|
|
49
|
+
*/
|
|
50
|
+
type ExternalizeLibs = {
|
|
51
|
+
default: boolean;
|
|
52
|
+
glob: string | string[];
|
|
53
|
+
};
|
|
54
|
+
type ResolveEnvs = {
|
|
55
|
+
default: boolean;
|
|
56
|
+
local: boolean;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Project configuration.
|
|
60
|
+
*
|
|
61
|
+
* @property {ProjectType} type - Type of the project.
|
|
62
|
+
* @property {string} path - Path of the project.
|
|
63
|
+
* @property {string} entry - Path of the file entry point.
|
|
64
|
+
* @property {string} name - Name of the project, it is also used to define the name of the library.
|
|
65
|
+
* @property {string} port - Server port.
|
|
66
|
+
* @property {boolean} debug - Print data purification data.
|
|
67
|
+
* @property {boolean} dts - Control if the .d.ts files are generated, by default it is True.
|
|
68
|
+
* @property {Partial<ResolveEnvs>} resolveEnvs - Flag for resolving environment.
|
|
69
|
+
* @property {boolean} shadowDom - If component is render into shadow dom.
|
|
70
|
+
* @property {Partial<ExternalizeLibs>} externalizeLibs - Configuration for externalizing libraries.
|
|
71
|
+
* @property {LibraryOptions['fileName']} fileName - Output file name for library.
|
|
72
|
+
* @property {string} fileName - Prefix for chunk file name.
|
|
73
|
+
* @property {ViteEnv} viteEnv - Vite environment configuration.
|
|
74
|
+
* @property {UserConfig} overrides - Overrides for vite configuration.
|
|
75
|
+
*/
|
|
76
|
+
interface ProjectConfig {
|
|
77
|
+
type: ProjectType;
|
|
78
|
+
path: string;
|
|
79
|
+
entry?: string;
|
|
80
|
+
name?: string;
|
|
81
|
+
port?: number;
|
|
82
|
+
logLevel?: LogLevel;
|
|
83
|
+
dts?: boolean;
|
|
84
|
+
resolveEnvs?: Partial<ResolveEnvs>;
|
|
85
|
+
shadowDom?: boolean;
|
|
86
|
+
externalizeLibs?: Partial<ExternalizeLibs>;
|
|
87
|
+
fileName?: LibraryOptions['fileName'];
|
|
88
|
+
chunkPrefix?: string;
|
|
89
|
+
viteEnv: ViteEnv;
|
|
90
|
+
overrides?: UserConfig;
|
|
91
|
+
}
|
|
92
|
+
interface ProjectConfigInitialized extends ProjectConfig {
|
|
93
|
+
name: string;
|
|
94
|
+
fileName: string;
|
|
95
|
+
chunkPrefix: string;
|
|
96
|
+
logLevel: LogLevel;
|
|
97
|
+
overrides: UserConfig;
|
|
98
|
+
shadowDom: boolean;
|
|
99
|
+
resolveEnvs: ResolveEnvs;
|
|
100
|
+
externalizeLibs: ExternalizeLibs;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Vite command details.
|
|
104
|
+
* @interface
|
|
105
|
+
* @property {Stage} stage - Stage of the project.
|
|
106
|
+
* @property {string} target - Command name.
|
|
107
|
+
* @property {Record<string, any>} flags - Flags for customize command.
|
|
108
|
+
*/
|
|
109
|
+
interface ViteCommand {
|
|
110
|
+
stage: Stage;
|
|
111
|
+
target: string;
|
|
112
|
+
flags: Record<string, any>;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Common project configuration.
|
|
116
|
+
*
|
|
117
|
+
* @property {string} envPrefix - Prefix in lowercase for environment variables and output files.
|
|
118
|
+
* @property {boolean} externalizeLibGlob - Glob expression or list of glob expressions to exclude
|
|
119
|
+
* dependencies from the package.json.
|
|
120
|
+
*/
|
|
121
|
+
interface CommonProjectConfig {
|
|
122
|
+
envPrefix: string;
|
|
123
|
+
externalizeLibGlob?: string | string[];
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Config builder context.
|
|
127
|
+
*
|
|
128
|
+
* @property {CommonProjectConfig} commonConfig - Common configuration for the project.
|
|
129
|
+
* @property {ProjectConfigInitialized} projectConfig - Initialized project configuration.
|
|
130
|
+
* @property {ViteCommandDetail} viteCmd - Vite command details.
|
|
131
|
+
*/
|
|
132
|
+
interface Context {
|
|
133
|
+
commonConfig: CommonProjectConfig;
|
|
134
|
+
projectConfig: ProjectConfigInitialized;
|
|
135
|
+
viteCmd: ViteCommand;
|
|
136
|
+
localPkgJson: Record<string, any>;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Interface for plugin configuration.
|
|
140
|
+
*/
|
|
141
|
+
interface PluginConfig {
|
|
142
|
+
/**
|
|
143
|
+
* Generates plugin(s) based on the provided configuration.
|
|
144
|
+
* @param {Context} ctx - The main configuration object.
|
|
145
|
+
* @returns {any[]} An array of plugins.
|
|
146
|
+
*/
|
|
147
|
+
generate: (ctx: Context) => any[];
|
|
148
|
+
/**
|
|
149
|
+
* Condition to determine if the plugin(s) should be included.
|
|
150
|
+
* @param {Context} ctx - The main configuration object.
|
|
151
|
+
* @returns {boolean} True if the plugin(s) should be included; false otherwise.
|
|
152
|
+
*/
|
|
153
|
+
condition?: (ctx: Context) => boolean;
|
|
154
|
+
}
|
|
155
|
+
export { ViteMode, Stage, ProjectType, Flag, Target, ViteEnv, ExternalizeLibs, ResolveEnvs, ProjectConfig, ProjectConfigInitialized, ViteCommand, CommonProjectConfig, Context, PluginConfig };
|
|
@@ -1,30 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: all[name]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
Flag: function() {
|
|
13
|
-
return Flag;
|
|
14
|
-
},
|
|
15
|
-
ProjectType: function() {
|
|
16
|
-
return ProjectType;
|
|
17
|
-
},
|
|
18
|
-
Stage: function() {
|
|
19
|
-
return Stage;
|
|
20
|
-
},
|
|
21
|
-
Target: function() {
|
|
22
|
-
return Target;
|
|
23
|
-
},
|
|
24
|
-
ViteMode: function() {
|
|
25
|
-
return ViteMode;
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
1
|
var ViteMode;
|
|
29
2
|
(function(ViteMode) {
|
|
30
3
|
ViteMode["PROD"] = "production";
|
|
@@ -56,3 +29,5 @@ var Target;
|
|
|
56
29
|
Target["PREVIEW"] = "preview";
|
|
57
30
|
Target["SERVE"] = "serve";
|
|
58
31
|
})(Target || (Target = {}));
|
|
32
|
+
|
|
33
|
+
export { Flag, ProjectType, Stage, Target, ViteMode };
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { PreRenderedChunk } from 'rollup';
|
|
2
|
+
import { PluginOption } from 'vite';
|
|
3
|
+
import { Context, PluginConfig } from "../types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Generates a short ID string.
|
|
6
|
+
*
|
|
7
|
+
* @param {number} length - The length of the ID to generate.
|
|
8
|
+
* @returns {string} - The generated ID.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* const id = shortId(10); // Outputs: "Aj3_Dk7_2j"
|
|
12
|
+
*/
|
|
13
|
+
declare const shortId: (length: number) => string;
|
|
14
|
+
/**
|
|
15
|
+
* Deeply merges two objects, combining their properties.
|
|
16
|
+
*
|
|
17
|
+
* @param {Record<string, any>} v1 - The first object.
|
|
18
|
+
* @param {Record<string, any>} v2 - The second object.
|
|
19
|
+
* @returns {Record<string, any>} - The merged object.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* const obj1 = { a: 1, b: { c: 2 } };
|
|
23
|
+
* const obj2 = { b: { d: 3 } };
|
|
24
|
+
* const merged = deepMerge(obj1, obj2); // Outputs: { a: 1, b: { c: 2, d: 3 } }
|
|
25
|
+
*/
|
|
26
|
+
declare function deepMerge(v1: Record<string, any>, v2: Record<string, any>): Record<string, any>;
|
|
27
|
+
/**
|
|
28
|
+
* Generates a name for js files.
|
|
29
|
+
*
|
|
30
|
+
* @param {string} [prefix] - An optional prefix for the chunk name.
|
|
31
|
+
* @returns - A function that takes an item and generates a chunk name.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* const generateChunkName = chunkName('prefix');
|
|
35
|
+
* const name = generateChunkName({ name: 'example' }); // Outputs: "prefix-example-Aj3_Dk7_2j.js"
|
|
36
|
+
*/
|
|
37
|
+
declare const chunkName: (prefix?: string) => (x: PreRenderedChunk) => string;
|
|
38
|
+
/**
|
|
39
|
+
* Returns the given object if the condition is true, otherwise returns null.
|
|
40
|
+
*
|
|
41
|
+
* @param {any} condition - The condition to evaluate.
|
|
42
|
+
* @param {Record<string, any>} obj - The object to return if the condition is true.
|
|
43
|
+
* @returns {Record<string, any> | null} - The object or null based on the condition.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* const obj = { a: 1 };
|
|
47
|
+
* const result = when(true, obj); // Outputs: { a: 1 }
|
|
48
|
+
* const result2 = when(false, obj); // Outputs: {}
|
|
49
|
+
*/
|
|
50
|
+
declare const when: (condition: any, obj: Record<string, any>) => Record<string, any>;
|
|
51
|
+
/**
|
|
52
|
+
* Filters and generates plugin configurations based on conditions and the provided context.
|
|
53
|
+
*
|
|
54
|
+
* @param {Context} ctx - The main configuration object.
|
|
55
|
+
* @returns {any[]} - An array of generated plugin configurations.
|
|
56
|
+
*/
|
|
57
|
+
declare const getPlugins: (ctx: Context, ...pluginConfigs: PluginConfig[]) => PluginOption[];
|
|
58
|
+
/**
|
|
59
|
+
* Gets the paths to the tsconfig files for all relevant projects.
|
|
60
|
+
*
|
|
61
|
+
* @returns {string[]} - An array containing paths to tsconfig files for both app and lib projects.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* const projects = {
|
|
65
|
+
* 'my-app': {
|
|
66
|
+
* type: 'app',
|
|
67
|
+
* data: { root: 'apps/my-app' }
|
|
68
|
+
* },
|
|
69
|
+
* 'my-lib': {
|
|
70
|
+
* type: 'lib',
|
|
71
|
+
* data: { root: 'libs/my-lib' }
|
|
72
|
+
* }
|
|
73
|
+
* };
|
|
74
|
+
*
|
|
75
|
+
* const tsConfigPaths = getTsConfigPaths(projects);
|
|
76
|
+
* console.log(tsConfigPaths);
|
|
77
|
+
* // Output:
|
|
78
|
+
* // ['apps/my-app/tsconfig.app.json', 'libs/my-lib/tsconfig.lib.json']
|
|
79
|
+
*/
|
|
80
|
+
declare const getNxTsConfigPaths: () => string[];
|
|
81
|
+
export { shortId, deepMerge, chunkName, when, getPlugins, getNxTsConfigPaths };
|