@gct-paas/build 0.1.6-dev.6 → 0.1.6-dev.8

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.
@@ -15,5 +15,7 @@ const DEFAULT_EXTERNAL = exports.DEFAULT_EXTERNAL = [
15
15
  "vuedraggable", "vue-grid-layout", "vant", "ant-design-vue", "vxe-table",
16
16
  // 图标库相关依赖
17
17
  "@ant-design/icons-vue", "@icon-park/vue-next/es/all", "@icon-park/vue-next/icons.json",
18
- // @gct-paas 相关依赖
19
- "@gct-paas/api", "@gct-paas/core", "@gct-paas/core-mobile", "@gct-paas/core-web", "@gct-paas/core-pad", "@gct-paas/design", "@gct-paas/design-mobile", "@gct-paas/design-web", "@gct-paas/design-pad", "@gct-paas/render", "@gct-paas/render-mobile", "@gct-paas/render-pad", "@gct-paas/render-web", "@gct-paas/schema", "@gct-paas/scss", "@gct-paas/platform-icons", "@gct-paas/vue-pdf"];
18
+ // @gct-paas 底包相关依赖
19
+ "@gct-paas/api", "@gct-paas/core", "@gct-paas/core-mobile", "@gct-paas/core-web", "@gct-paas/core-pad", "@gct-paas/design", "@gct-paas/design-mobile", "@gct-paas/design-web", "@gct-paas/design-pad", "@gct-paas/render", "@gct-paas/render-mobile", "@gct-paas/render-pad", "@gct-paas/render-web", "@gct-paas/schema", "@gct-paas/scss",
20
+ // @gct-paas 独立组件库
21
+ "@gct-paas/platform-icons", "@gct-paas/vue-pdf", "@gct-paas/vue-video-player"];
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isBuildPluginEnv = isBuildPluginEnv;
7
+ function isBuildPluginEnv() {
8
+ return process.env.BUILD_PLUGIN_ENV === "true";
9
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * 是否为需要线上插件开发环境
3
+ *
4
+ * @export
5
+ * @return {*} {boolean}
6
+ */
7
+ export declare function isBuildPluginEnv(): boolean;
@@ -15,10 +15,17 @@ Object.defineProperty(exports, "IS_NODE_MODULE", {
15
15
  return _regExp.IS_NODE_MODULE;
16
16
  }
17
17
  });
18
+ Object.defineProperty(exports, "isBuildPluginEnv", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _envState.isBuildPluginEnv;
22
+ }
23
+ });
18
24
  exports.mergeConfig = mergeConfig;
19
25
  exports.unixToWinPath = unixToWinPath;
20
26
  exports.winToUnixPath = winToUnixPath;
21
27
  var _lodashEs = require("lodash-es");
28
+ var _envState = require("./env-state/env-state.cjs");
22
29
  var _regExp = require("./reg-exp/reg-exp.cjs");
23
30
  var _watcher = require("./watcher/watcher.cjs");
24
31
  function winToUnixPath(pathStr) {
@@ -1,3 +1,4 @@
1
+ export { isBuildPluginEnv } from './env-state/env-state';
1
2
  export { IS_NODE_MODULE } from './reg-exp/reg-exp';
2
3
  export { CopyWatch } from './watcher/watcher';
3
4
  /**
@@ -16,12 +16,18 @@ function defineViteConfig(opts = {}) {
16
16
  build: {
17
17
  minify: "terser",
18
18
  terserOptions: {
19
+ // 压缩选项,控制代码压缩行为
19
20
  compress: {
21
+ // 是否移除 console.* 调用;false 表示保留,避免生产环境丢失重要日志
20
22
  drop_console: false,
23
+ // 是否移除永远不会执行的死代码(如 if(false){...})
21
24
  dead_code: true,
25
+ // 是否移除未被引用的变量和函数,减小产物体积
22
26
  unused: true,
27
+ // 压缩算法的执行轮数;多轮压缩可以发现单轮无法消除的冗余代码,但会增加构建耗时
23
28
  passes: 2
24
29
  },
30
+ // 是否混淆变量名、函数名等标识符,使产物更难以阅读反编译,同时进一步缩小体积
25
31
  mangle: true
26
32
  },
27
33
  lib: {
@@ -80,12 +80,12 @@ function definePkgDevViteConfig(opts = {}) {
80
80
  },
81
81
  // 排除测试目录,以及测试文件
82
82
  exclude: ["**/test/**", "**/*.test.ts", "**/*.test.tsx", "**/*.spec.ts", "**/*.spec.tsx"]
83
- }), (0, _vitePluginStaticCopy.viteStaticCopy)({
83
+ }), ...((0, _fs.existsSync)(_path.default.resolve(cwd, "src/types")) ? [(0, _vitePluginStaticCopy.viteStaticCopy)({
84
84
  targets: [{
85
85
  // 将 src/types 目录下的文件复制到编译输出目录
86
86
  src: "src/types",
87
87
  dest: "."
88
88
  }]
89
- })]
89
+ })] : [])]
90
90
  }), opts);
91
91
  }
@@ -24,6 +24,22 @@ function definePluginViteConfig(opts = {}) {
24
24
  exclude: _constants.DEFAULT_EXTERNAL
25
25
  },
26
26
  build: {
27
+ minify: isProd ? "terser" : false,
28
+ terserOptions: {
29
+ // 压缩选项,控制代码压缩行为
30
+ compress: {
31
+ // 是否移除 console.* 调用;false 表示保留,避免生产环境丢失重要日志
32
+ drop_console: false,
33
+ // 是否移除永远不会执行的死代码(如 if(false){...})
34
+ dead_code: true,
35
+ // 是否移除未被引用的变量和函数,减小产物体积
36
+ unused: true,
37
+ // 压缩算法的执行轮数;多轮压缩可以发现单轮无法消除的冗余代码,但会增加构建耗时
38
+ passes: 2
39
+ },
40
+ // 是否混淆变量名、函数名等标识符,使产物更难以阅读反编译,同时进一步缩小体积
41
+ mangle: true
42
+ },
27
43
  lib: {
28
44
  entry: isProd ? loaderEntry : entry,
29
45
  formats: ["es"],
@@ -12,6 +12,7 @@ var _path = _interopRequireDefault(require("path"));
12
12
  var _fsExtra = _interopRequireDefault(require("fs-extra"));
13
13
  var _util = require("../../util/index.cjs");
14
14
  var _constants = require("../../constants/index.cjs");
15
+ var _injectImportmapPlugin = require("../vite-plugins/inject-importmap-plugin.cjs");
15
16
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
16
17
  function defineProjectViteConfig(opts = {}) {
17
18
  return (0, _vite.defineConfig)(async () => {
@@ -55,7 +56,7 @@ function defineProjectViteConfig(opts = {}) {
55
56
  },
56
57
  plugins: [(0, _pluginVue.default)(), (0, _pluginVueJsx.default)(), (0, _vite2.default)({
57
58
  hmrTopLevelAwait: false
58
- })]
59
+ }), (0, _injectImportmapPlugin.injectImportMapPlugin)()]
59
60
  }, opts);
60
61
  });
61
62
  }
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.injectImportMapPlugin = injectImportMapPlugin;
7
+ var _nodeFs = _interopRequireDefault(require("node:fs"));
8
+ var _nodePath = _interopRequireDefault(require("node:path"));
9
+ var _simpleGit = require("simple-git");
10
+ var _util = require("../../util/index.cjs");
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
+ const DEV_IMPORT_MAP_PREFIX = ["/plugin-kit/@id/", "/plugin-design/@id/", "/plugin-render-mobile/@id/", "/plugin-render-pad/@id/", "/plugin-render-web/@id/"];
13
+ function injectImportMapPlugin(options = {}) {
14
+ const {
15
+ repoUrl = "https://git.gct-china.com/paas/frontend/gct-paas-cdn.git",
16
+ filePath = "extras/import-map.json"
17
+ } = options;
18
+ let importMapContent = "{}";
19
+ return {
20
+ name: "gct-vite-plugin:inject-importmap",
21
+ apply: "build",
22
+ async buildStart() {
23
+ const cwd = process.cwd();
24
+ let targetBranch = options.branch;
25
+ if (!targetBranch) {
26
+ targetBranch = process.env.CI_COMMIT_BRANCH || process.env.CI_BUILD_REF_NAME;
27
+ if (!targetBranch) {
28
+ const cwdGit = (0, _simpleGit.simpleGit)(cwd);
29
+ try {
30
+ const raw = await cwdGit.revparse(["--abbrev-ref", "HEAD"]);
31
+ const resolved = raw.trim();
32
+ if (resolved && resolved !== "HEAD") {
33
+ targetBranch = resolved;
34
+ }
35
+ } catch {}
36
+ }
37
+ if (!targetBranch) {
38
+ this.error("\u65E0\u6CD5\u81EA\u52A8\u83B7\u53D6\u5F53\u524D git \u5206\u652F\uFF1A\u5F53\u524D\u53EF\u80FD\u5904\u4E8E\u6E38\u79BB HEAD\uFF08detached HEAD\uFF09\u72B6\u6001\uFF08CI \u73AF\u5883\u5E38\u89C1\uFF09\u3002\u8BF7\u901A\u8FC7 options.branch \u660E\u786E\u6307\u5B9A\u5206\u652F\u540D\uFF0C\u6216\u786E\u4FDD\u73AF\u5883\u53D8\u91CF CI_COMMIT_BRANCH / CI_BUILD_REF_NAME \u5DF2\u8BBE\u7F6E\u3002");
39
+ }
40
+ }
41
+ const cacheDir = _nodePath.default.resolve(cwd, "node_modules/.gct/cache/importmap-repo-cache");
42
+ try {
43
+ if (!_nodeFs.default.existsSync(cacheDir)) {
44
+ _nodeFs.default.mkdirSync(cacheDir, {
45
+ recursive: true
46
+ });
47
+ const git2 = (0, _simpleGit.simpleGit)(cacheDir);
48
+ await git2.init();
49
+ await git2.addRemote("origin", repoUrl);
50
+ await git2.raw(["config", "core.sparseCheckout", "true"]);
51
+ _nodeFs.default.writeFileSync(_nodePath.default.join(cacheDir, ".git/info/sparse-checkout"), filePath);
52
+ }
53
+ const git = (0, _simpleGit.simpleGit)(cacheDir);
54
+ await git.remote(["set-url", "origin", repoUrl]);
55
+ await git.fetch("origin", targetBranch, {
56
+ "--depth": 1
57
+ });
58
+ await git.reset(["--hard", `origin/${targetBranch}`]);
59
+ const targetFilePath = _nodePath.default.join(cacheDir, filePath);
60
+ if (!_nodeFs.default.existsSync(targetFilePath)) {
61
+ this.error(`\u5728\u4ED3\u5E93 ${repoUrl} \u7684 ${targetBranch} \u5206\u652F\u4E2D\uFF0C\u672A\u627E\u5230\u6587\u4EF6: ${filePath}\u3002`);
62
+ }
63
+ const rawContent = _nodeFs.default.readFileSync(targetFilePath, "utf-8");
64
+ try {
65
+ const parsed = JSON.parse(rawContent);
66
+ if ((0, _util.isBuildPluginEnv)() && parsed.imports) {
67
+ const keys = Object.keys(parsed.imports);
68
+ DEV_IMPORT_MAP_PREFIX.forEach(prefix => {
69
+ keys.forEach(key => {
70
+ const val = parsed.imports[key];
71
+ parsed.imports[prefix + key] = val;
72
+ });
73
+ });
74
+ }
75
+ importMapContent = JSON.stringify(parsed);
76
+ } catch (parseError) {
77
+ this.error(`\u76EE\u6807\u6587\u4EF6 ${filePath} \u5305\u542B\u975E\u6CD5\u7684 JSON \u683C\u5F0F: ${parseError}`);
78
+ }
79
+ } catch (error) {
80
+ this.error(`\u4ECE Git \u4ED3\u5E93\u62C9\u53D6\u6216\u8BFB\u53D6 import-map.json \u65F6\u53D1\u751F\u9519\u8BEF: ${error}`);
81
+ }
82
+ },
83
+ transformIndexHtml() {
84
+ return [{
85
+ tag: "script",
86
+ attrs: {
87
+ type: "importmap"
88
+ },
89
+ injectTo: "head-prepend",
90
+ children: importMapContent
91
+ }];
92
+ }
93
+ };
94
+ }
@@ -0,0 +1,19 @@
1
+ import type { Plugin } from 'vite';
2
+ export interface InjectImportMapPluginOptions {
3
+ /**
4
+ * 仓库地址,默认为 https://git.gct-china.com/paas/frontend/gct-paas-cdn.git
5
+ */
6
+ repoUrl?: string;
7
+ /**
8
+ * 需要读取的文件路径,默认为 extras/import-map.json
9
+ */
10
+ filePath?: string;
11
+ /**
12
+ * 指定分支,若未指定则自动获取当前主工程对应的分支
13
+ */
14
+ branch?: string;
15
+ }
16
+ /**
17
+ * 编译时读取并注入 import-map 配置的插件
18
+ */
19
+ export declare function injectImportMapPlugin(options?: InjectImportMapPluginOptions): Plugin;
@@ -32,7 +32,7 @@ export const DEFAULT_EXTERNAL = [
32
32
  "@ant-design/icons-vue",
33
33
  "@icon-park/vue-next/es/all",
34
34
  "@icon-park/vue-next/icons.json",
35
- // @gct-paas 相关依赖
35
+ // @gct-paas 底包相关依赖
36
36
  "@gct-paas/api",
37
37
  "@gct-paas/core",
38
38
  "@gct-paas/core-mobile",
@@ -48,6 +48,8 @@ export const DEFAULT_EXTERNAL = [
48
48
  "@gct-paas/render-web",
49
49
  "@gct-paas/schema",
50
50
  "@gct-paas/scss",
51
+ // @gct-paas 独立组件库
51
52
  "@gct-paas/platform-icons",
52
- "@gct-paas/vue-pdf"
53
+ "@gct-paas/vue-pdf",
54
+ "@gct-paas/vue-video-player"
53
55
  ];
@@ -0,0 +1,7 @@
1
+ /**
2
+ * 是否为需要线上插件开发环境
3
+ *
4
+ * @export
5
+ * @return {*} {boolean}
6
+ */
7
+ export declare function isBuildPluginEnv(): boolean;
@@ -0,0 +1,3 @@
1
+ export function isBuildPluginEnv() {
2
+ return process.env.BUILD_PLUGIN_ENV === "true";
3
+ }
@@ -1,3 +1,4 @@
1
+ export { isBuildPluginEnv } from './env-state/env-state';
1
2
  export { IS_NODE_MODULE } from './reg-exp/reg-exp';
2
3
  export { CopyWatch } from './watcher/watcher';
3
4
  /**
package/es/util/index.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  import { mergeWith } from "lodash-es";
2
+ export { isBuildPluginEnv } from "./env-state/env-state.mjs";
2
3
  export { IS_NODE_MODULE } from "./reg-exp/reg-exp.mjs";
3
4
  export { CopyWatch } from "./watcher/watcher.mjs";
4
5
  export function winToUnixPath(pathStr) {
@@ -10,12 +10,18 @@ export function defineViteConfig(opts = {}) {
10
10
  build: {
11
11
  minify: "terser",
12
12
  terserOptions: {
13
+ // 压缩选项,控制代码压缩行为
13
14
  compress: {
15
+ // 是否移除 console.* 调用;false 表示保留,避免生产环境丢失重要日志
14
16
  drop_console: false,
17
+ // 是否移除永远不会执行的死代码(如 if(false){...})
15
18
  dead_code: true,
19
+ // 是否移除未被引用的变量和函数,减小产物体积
16
20
  unused: true,
21
+ // 压缩算法的执行轮数;多轮压缩可以发现单轮无法消除的冗余代码,但会增加构建耗时
17
22
  passes: 2
18
23
  },
24
+ // 是否混淆变量名、函数名等标识符,使产物更难以阅读反编译,同时进一步缩小体积
19
25
  mangle: true
20
26
  },
21
27
  lib: {
@@ -6,7 +6,7 @@ import vueJsx from "@vitejs/plugin-vue-jsx";
6
6
  import { libInjectCss } from "vite-plugin-lib-inject-css";
7
7
  import { viteStaticCopy } from "vite-plugin-static-copy";
8
8
  import dts from "vite-plugin-dts";
9
- import { readFileSync } from "fs";
9
+ import { readFileSync, existsSync } from "fs";
10
10
  import { mergeConfig, IS_NODE_MODULE } from "../../util/index.mjs";
11
11
  import { DEFAULT_EXTERNAL } from "../../constants/index.mjs";
12
12
  export function definePkgDevViteConfig(opts = {}) {
@@ -82,15 +82,17 @@ export function definePkgDevViteConfig(opts = {}) {
82
82
  "**/*.spec.tsx"
83
83
  ]
84
84
  }),
85
- viteStaticCopy({
86
- targets: [
87
- {
88
- // 将 src/types 目录下的文件复制到编译输出目录
89
- src: "src/types",
90
- dest: "."
91
- }
92
- ]
93
- })
85
+ ...existsSync(path.resolve(cwd, "src/types")) ? [
86
+ viteStaticCopy({
87
+ targets: [
88
+ {
89
+ // src/types 目录下的文件复制到编译输出目录
90
+ src: "src/types",
91
+ dest: "."
92
+ }
93
+ ]
94
+ })
95
+ ] : []
94
96
  ]
95
97
  }),
96
98
  opts
@@ -14,6 +14,22 @@ export function definePluginViteConfig(opts = {}) {
14
14
  exclude: DEFAULT_EXTERNAL
15
15
  },
16
16
  build: {
17
+ minify: isProd ? "terser" : false,
18
+ terserOptions: {
19
+ // 压缩选项,控制代码压缩行为
20
+ compress: {
21
+ // 是否移除 console.* 调用;false 表示保留,避免生产环境丢失重要日志
22
+ drop_console: false,
23
+ // 是否移除永远不会执行的死代码(如 if(false){...})
24
+ dead_code: true,
25
+ // 是否移除未被引用的变量和函数,减小产物体积
26
+ unused: true,
27
+ // 压缩算法的执行轮数;多轮压缩可以发现单轮无法消除的冗余代码,但会增加构建耗时
28
+ passes: 2
29
+ },
30
+ // 是否混淆变量名、函数名等标识符,使产物更难以阅读反编译,同时进一步缩小体积
31
+ mangle: true
32
+ },
17
33
  lib: {
18
34
  entry: isProd ? loaderEntry : entry,
19
35
  formats: ["es"],
@@ -8,6 +8,7 @@ import path from "path";
8
8
  import fse from "fs-extra";
9
9
  import { mergeConfig } from "../../util/index.mjs";
10
10
  import { DEFAULT_EXTERNAL } from "../../constants/index.mjs";
11
+ import { injectImportMapPlugin } from "../vite-plugins/inject-importmap-plugin.mjs";
11
12
  export function defineProjectViteConfig(opts = {}) {
12
13
  return defineConfig(async () => {
13
14
  const cwd = process.cwd();
@@ -52,7 +53,8 @@ export function defineProjectViteConfig(opts = {}) {
52
53
  plugins: [
53
54
  vue(),
54
55
  vueJsx(),
55
- UnoCSS({ hmrTopLevelAwait: false })
56
+ UnoCSS({ hmrTopLevelAwait: false }),
57
+ injectImportMapPlugin()
56
58
  ]
57
59
  },
58
60
  opts
@@ -0,0 +1,19 @@
1
+ import type { Plugin } from 'vite';
2
+ export interface InjectImportMapPluginOptions {
3
+ /**
4
+ * 仓库地址,默认为 https://git.gct-china.com/paas/frontend/gct-paas-cdn.git
5
+ */
6
+ repoUrl?: string;
7
+ /**
8
+ * 需要读取的文件路径,默认为 extras/import-map.json
9
+ */
10
+ filePath?: string;
11
+ /**
12
+ * 指定分支,若未指定则自动获取当前主工程对应的分支
13
+ */
14
+ branch?: string;
15
+ }
16
+ /**
17
+ * 编译时读取并注入 import-map 配置的插件
18
+ */
19
+ export declare function injectImportMapPlugin(options?: InjectImportMapPluginOptions): Plugin;
@@ -0,0 +1,86 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { simpleGit } from "simple-git";
4
+ import { isBuildPluginEnv } from "../../util/index.mjs";
5
+ const DEV_IMPORT_MAP_PREFIX = ["/plugin-kit/@id/", "/plugin-design/@id/", "/plugin-render-mobile/@id/", "/plugin-render-pad/@id/", "/plugin-render-web/@id/"];
6
+ export function injectImportMapPlugin(options = {}) {
7
+ const {
8
+ repoUrl = "https://git.gct-china.com/paas/frontend/gct-paas-cdn.git",
9
+ filePath = "extras/import-map.json"
10
+ } = options;
11
+ let importMapContent = "{}";
12
+ return {
13
+ name: "gct-vite-plugin:inject-importmap",
14
+ apply: "build",
15
+ async buildStart() {
16
+ const cwd = process.cwd();
17
+ let targetBranch = options.branch;
18
+ if (!targetBranch) {
19
+ targetBranch = process.env.CI_COMMIT_BRANCH || process.env.CI_BUILD_REF_NAME;
20
+ if (!targetBranch) {
21
+ const cwdGit = simpleGit(cwd);
22
+ try {
23
+ const raw = await cwdGit.revparse(["--abbrev-ref", "HEAD"]);
24
+ const resolved = raw.trim();
25
+ if (resolved && resolved !== "HEAD") {
26
+ targetBranch = resolved;
27
+ }
28
+ } catch {
29
+ }
30
+ }
31
+ if (!targetBranch) {
32
+ this.error(
33
+ "\u65E0\u6CD5\u81EA\u52A8\u83B7\u53D6\u5F53\u524D git \u5206\u652F\uFF1A\u5F53\u524D\u53EF\u80FD\u5904\u4E8E\u6E38\u79BB HEAD\uFF08detached HEAD\uFF09\u72B6\u6001\uFF08CI \u73AF\u5883\u5E38\u89C1\uFF09\u3002\u8BF7\u901A\u8FC7 options.branch \u660E\u786E\u6307\u5B9A\u5206\u652F\u540D\uFF0C\u6216\u786E\u4FDD\u73AF\u5883\u53D8\u91CF CI_COMMIT_BRANCH / CI_BUILD_REF_NAME \u5DF2\u8BBE\u7F6E\u3002"
34
+ );
35
+ }
36
+ }
37
+ const cacheDir = path.resolve(cwd, "node_modules/.gct/cache/importmap-repo-cache");
38
+ try {
39
+ if (!fs.existsSync(cacheDir)) {
40
+ fs.mkdirSync(cacheDir, { recursive: true });
41
+ const git2 = simpleGit(cacheDir);
42
+ await git2.init();
43
+ await git2.addRemote("origin", repoUrl);
44
+ await git2.raw(["config", "core.sparseCheckout", "true"]);
45
+ fs.writeFileSync(path.join(cacheDir, ".git/info/sparse-checkout"), filePath);
46
+ }
47
+ const git = simpleGit(cacheDir);
48
+ await git.remote(["set-url", "origin", repoUrl]);
49
+ await git.fetch("origin", targetBranch, { "--depth": 1 });
50
+ await git.reset(["--hard", `origin/${targetBranch}`]);
51
+ const targetFilePath = path.join(cacheDir, filePath);
52
+ if (!fs.existsSync(targetFilePath)) {
53
+ this.error(`\u5728\u4ED3\u5E93 ${repoUrl} \u7684 ${targetBranch} \u5206\u652F\u4E2D\uFF0C\u672A\u627E\u5230\u6587\u4EF6: ${filePath}\u3002`);
54
+ }
55
+ const rawContent = fs.readFileSync(targetFilePath, "utf-8");
56
+ try {
57
+ const parsed = JSON.parse(rawContent);
58
+ if (isBuildPluginEnv() && parsed.imports) {
59
+ const keys = Object.keys(parsed.imports);
60
+ DEV_IMPORT_MAP_PREFIX.forEach((prefix) => {
61
+ keys.forEach((key) => {
62
+ const val = parsed.imports[key];
63
+ parsed.imports[prefix + key] = val;
64
+ });
65
+ });
66
+ }
67
+ importMapContent = JSON.stringify(parsed);
68
+ } catch (parseError) {
69
+ this.error(`\u76EE\u6807\u6587\u4EF6 ${filePath} \u5305\u542B\u975E\u6CD5\u7684 JSON \u683C\u5F0F: ${parseError}`);
70
+ }
71
+ } catch (error) {
72
+ this.error(`\u4ECE Git \u4ED3\u5E93\u62C9\u53D6\u6216\u8BFB\u53D6 import-map.json \u65F6\u53D1\u751F\u9519\u8BEF: ${error}`);
73
+ }
74
+ },
75
+ transformIndexHtml() {
76
+ return [
77
+ {
78
+ tag: "script",
79
+ attrs: { type: "importmap" },
80
+ injectTo: "head-prepend",
81
+ children: importMapContent
82
+ }
83
+ ];
84
+ }
85
+ };
86
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gct-paas/build",
3
- "version": "0.1.6-dev.6",
3
+ "version": "0.1.6-dev.8",
4
4
  "type": "module",
5
5
  "description": "paas 平台核心包",
6
6
  "main": "dist/index.cjs",
@@ -71,6 +71,7 @@
71
71
  "prettier": "^3.8.1",
72
72
  "rimraf": "^6.1.3",
73
73
  "sass": "^1.98.0",
74
+ "simple-git": "^3.33.0",
74
75
  "stylelint": "~16.26.1",
75
76
  "stylelint-config-recess-order": "~7.4.0",
76
77
  "stylelint-config-standard-scss": "~16.0.0",
@@ -98,6 +99,5 @@
98
99
  },
99
100
  "peerDependencies": {
100
101
  "@gct-paas/scss": "*"
101
- },
102
- "gitHead": "2e48c22f823afd42f491f0df915aeca837964f19"
102
+ }
103
103
  }