@gct-paas/build 0.1.4-dev.3 → 0.1.4-dev.5

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.
@@ -6,4 +6,4 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.PROD_MODE = exports.DEV_MODE = exports.DEFAULT_EXTERNAL = void 0;
7
7
  const DEV_MODE = exports.DEV_MODE = "development";
8
8
  const PROD_MODE = exports.PROD_MODE = "production";
9
- const DEFAULT_EXTERNAL = exports.DEFAULT_EXTERNAL = ["vue", "vue-router", "vue-i18n", "axios", "dayjs", "lodash-es", "qs", "pinia", "vuedraggable", "sortablejs", "vue-grid-layout", "vant", "ant-design-vue", "@gct-paas/build", "@gct-paas/core", "@gct-paas/core-mobile", "@gct-paas/core-web", "@gct-paas/design", "@gct-paas/design-mobile", "@gct-paas/design-web", "@gct-paas/mobile", "@gct-paas/scss", "@gct-paas/web", "systemjs"];
9
+ const DEFAULT_EXTERNAL = exports.DEFAULT_EXTERNAL = ["vue", "vue-router", "vue-i18n", "axios", "dayjs", "lodash-es", "qs", "pinia", "vuedraggable", "sortablejs", "vue-grid-layout", "vant", "ant-design-vue", "@gct-paas/build", "@gct-paas/api", "@gct-paas/core", "@gct-paas/core-mobile", "@gct-paas/core-web", "@gct-paas/design", "@gct-paas/design-mobile", "@gct-paas/design-web", "@gct-paas/mobile", "@gct-paas/scss", "@gct-paas/web", "systemjs"];
@@ -73,6 +73,7 @@ function defineRollupConfig(opts = {}) {
73
73
  }
74
74
  const output = [{
75
75
  dir: outDir,
76
+ esModule: true,
76
77
  format: "es",
77
78
  sourcemap: false,
78
79
  preserveModules: true,
@@ -82,7 +83,15 @@ function defineRollupConfig(opts = {}) {
82
83
  return (0, _util.mergeConfig)((0, _rollup.defineConfig)({
83
84
  input,
84
85
  treeshake: false,
85
- external: _constants.DEFAULT_EXTERNAL,
86
+ external: id => {
87
+ if (_util.IS_NODE_MODULE.test(id)) {
88
+ return true;
89
+ }
90
+ if (_constants.DEFAULT_EXTERNAL.includes(id)) {
91
+ return true;
92
+ }
93
+ return false;
94
+ },
86
95
  output,
87
96
  plugins: [(0, _rollupPlugins.ignoreCompilerFile)(externalCompileFileReg), (0, _pluginJson.default)(), (0, _pluginVue.default)({
88
97
  isProduction: isProd
@@ -9,10 +9,17 @@ Object.defineProperty(exports, "CopyWatch", {
9
9
  return _watcher.CopyWatch;
10
10
  }
11
11
  });
12
+ Object.defineProperty(exports, "IS_NODE_MODULE", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _regExp.IS_NODE_MODULE;
16
+ }
17
+ });
12
18
  exports.mergeConfig = mergeConfig;
13
19
  exports.unixToWinPath = unixToWinPath;
14
20
  exports.winToUnixPath = winToUnixPath;
15
21
  var _lodashEs = require("lodash-es");
22
+ var _regExp = require("./reg-exp/reg-exp.cjs");
16
23
  var _watcher = require("./watcher/watcher.cjs");
17
24
  function winToUnixPath(pathStr) {
18
25
  return pathStr.replace(/\\/g, "/");
@@ -22,7 +29,7 @@ function unixToWinPath(pathStr) {
22
29
  }
23
30
  function mergeConfig(obj, obj2) {
24
31
  return (0, _lodashEs.mergeWith)(obj, obj2, (objValue, srcValue) => {
25
- if (Array.isArray(objValue)) {
32
+ if (Array.isArray(objValue) && Array.isArray(srcValue)) {
26
33
  return objValue.concat(srcValue);
27
34
  }
28
35
  return void 0;
@@ -1,3 +1,4 @@
1
+ export { IS_NODE_MODULE } from './reg-exp/reg-exp';
1
2
  export { CopyWatch } from './watcher/watcher';
2
3
  /**
3
4
  * win 路径 \\ 转 linux 路径 /
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.IS_NODE_MODULE = void 0;
7
+ const IS_NODE_MODULE = exports.IS_NODE_MODULE = /node_modules\//;
@@ -0,0 +1 @@
1
+ export declare const IS_NODE_MODULE: RegExp;
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,18 @@
1
+ /**
2
+ * 项目自定义配置接口
3
+ *
4
+ * @author chitanda
5
+ * @date 2025-08-24 11:08:43
6
+ * @export
7
+ * @interface GctOpts
8
+ */
9
+ export interface GctOpts {
10
+ /**
11
+ * HTTP 代理配置,根据分支前缀匹配
12
+ *
13
+ * @author chitanda
14
+ * @date 2025-08-24 11:08:56
15
+ * @type {Record<string, string>}
16
+ */
17
+ httpProxyConfig: Record<string, string>;
18
+ }
@@ -21,6 +21,12 @@ Object.defineProperty(exports, "defineMobilePluginViteConfig", {
21
21
  return _vitePluginConfig.defineMobilePluginViteConfig;
22
22
  }
23
23
  });
24
+ Object.defineProperty(exports, "defineProjectViteConfig", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _viteProjectConfig.defineProjectViteConfig;
28
+ }
29
+ });
24
30
  Object.defineProperty(exports, "defineViteBaseConfig", {
25
31
  enumerable: true,
26
32
  get: function () {
@@ -42,4 +48,5 @@ Object.defineProperty(exports, "defineWebPluginViteConfig", {
42
48
  var _viteBaseConfig = require("./vite-config/vite-base-config.cjs");
43
49
  var _viteConfig = require("./vite-config/vite-config.cjs");
44
50
  var _viteDevConfig = require("./vite-config/vite-dev-config.cjs");
45
- var _vitePluginConfig = require("./vite-config/vite-plugin-config.cjs");
51
+ var _vitePluginConfig = require("./vite-config/vite-plugin-config.cjs");
52
+ var _viteProjectConfig = require("./vite-config/vite-project-config.cjs");
@@ -2,3 +2,4 @@ export { defineViteBaseConfig } from './vite-config/vite-base-config';
2
2
  export { defineViteConfig } from './vite-config/vite-config';
3
3
  export { defineDevViteConfig } from './vite-config/vite-dev-config';
4
4
  export { defineDesignPluginViteConfig, defineMobilePluginViteConfig, defineWebPluginViteConfig, } from './vite-config/vite-plugin-config';
5
+ export { defineProjectViteConfig } from './vite-config/vite-project-config';
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.defineProjectViteConfig = defineProjectViteConfig;
7
+ var _vite = require("vite");
8
+ var _pluginVue = _interopRequireDefault(require("@vitejs/plugin-vue"));
9
+ var _pluginVueJsx = _interopRequireDefault(require("@vitejs/plugin-vue-jsx"));
10
+ var _pluginLegacy = _interopRequireDefault(require("@vitejs/plugin-legacy"));
11
+ var _pluginJson = _interopRequireDefault(require("@rollup/plugin-json"));
12
+ var _path = _interopRequireDefault(require("path"));
13
+ var _fsExtra = _interopRequireDefault(require("fs-extra"));
14
+ var _simpleGit = require("simple-git");
15
+ var _util = require("../../util/index.cjs");
16
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
17
+ const gctOptsDefault = {
18
+ httpProxyConfig: {
19
+ alpha: "http://paas.alpha.gct-paas.com",
20
+ beta: "http://paas.beta.gct-paas.com",
21
+ "paas-ai-dev": "http://paas.aidev.gct-paas.com",
22
+ "paas-dev": "http://paas.paasdev.gct-paas.com",
23
+ "paas-test": "http://paas.paastest.gct-paas.com",
24
+ "mom-dev": "http://paas.momdev.gct-paas.com",
25
+ "mom-test": "http://paas.momtest.gct-paas.com",
26
+ "ncdp-dev": "http://paas.ncdpdev.gct-paas.com",
27
+ "ncdp-test": "http://paas.ncdptest.gct-paas.com",
28
+ "ipaas-dev": "http://paas.ipaasdev.gct-paas.com",
29
+ "ipaas-test": "http://paas.ipaastest.gct-paas.com",
30
+ "edhr-dev": "http://paas.edhrdev.gct-paas.com",
31
+ "edhr-test": "http://paas.edhrtest.gct-paas.com",
32
+ "datav-dev": "http://paas.datavdev.gct-paas.com"
33
+ }
34
+ };
35
+ function defineProjectViteConfig(gctOpts = {}, opts = {}) {
36
+ const _gctOpts = (0, _util.mergeConfig)(gctOptsDefault, gctOpts);
37
+ return (0, _vite.defineConfig)(async () => {
38
+ const cwd = process.cwd();
39
+ const pkg = _fsExtra.default.readJsonSync(_path.default.resolve(cwd, "package.json"));
40
+ const git = (0, _simpleGit.simpleGit)({
41
+ baseDir: cwd
42
+ });
43
+ const branchSummary = await git.branch();
44
+ const httpProxyKey = Object.keys(_gctOpts.httpProxyConfig).find(key => {
45
+ return key.startsWith(branchSummary.current);
46
+ }) || "paas-dev";
47
+ const httpProxy = _gctOpts.httpProxyConfig[httpProxyKey];
48
+ return (0, _util.mergeConfig)({
49
+ resolve: {
50
+ alias: {
51
+ "@": _path.default.resolve(cwd, "src")
52
+ }
53
+ },
54
+ build: {
55
+ rollupOptions: {
56
+ external: ["core-js", "vue", "vue-i18n", "vue-router", "ant-design-vue", "pinia", "systemjs", "@gct-paas/core", "@gct-paas/core-web", "@gct-paas/api"]
57
+ }
58
+ },
59
+ css: {
60
+ preprocessorOptions: {
61
+ scss: {
62
+ additionalData: `@use "@gct-paas/scss/style/global.scss" as *;`
63
+ }
64
+ }
65
+ },
66
+ server: {
67
+ host: "0.0.0.0",
68
+ cors: true,
69
+ fs: {
70
+ strict: false
71
+ },
72
+ proxy: {
73
+ hostname: "0.0.0.0",
74
+ ...["/gct-platform", "/gct-apaas", "/gct-ipaas", "/minio"].reduce((acc, item) => {
75
+ acc[item] = httpProxy;
76
+ return acc;
77
+ }, {})
78
+ }
79
+ },
80
+ define: {
81
+ "import.meta.env.pkg": {
82
+ name: pkg.name,
83
+ version: pkg.version
84
+ }
85
+ },
86
+ plugins: [(0, _pluginJson.default)(), (0, _pluginVue.default)(), (0, _pluginVueJsx.default)(), (0, _pluginLegacy.default)({
87
+ targets: ["chrome>=85", "edge>=85", "firefox>=79", "safari>=14.1"],
88
+ externalSystemJS: true,
89
+ // 关键配置:只生成 legacy 版本
90
+ renderModernChunks: false
91
+ })]
92
+ }, opts);
93
+ });
94
+ }
@@ -0,0 +1,13 @@
1
+ import { UserConfig, UserConfigFnPromise } from 'vite';
2
+ import { GctOpts } from '../gct-opts.interface';
3
+ /**
4
+ * 构建本地开发 project 项目 vite 通用配置,基于此配置构建其他 vite 配置
5
+ * 参数合并时,数组会被合并而不是被替换
6
+ *
7
+ * @author chitanda
8
+ * @date 2025-08-24 11:08:04
9
+ * @export
10
+ * @param {UserConfig} [opts={}]
11
+ * @returns {*} {Promise<UserConfig>}
12
+ */
13
+ export declare function defineProjectViteConfig(gctOpts?: Partial<GctOpts>, opts?: UserConfig): UserConfigFnPromise;
@@ -15,6 +15,7 @@ export const DEFAULT_EXTERNAL = [
15
15
  "vant",
16
16
  "ant-design-vue",
17
17
  "@gct-paas/build",
18
+ "@gct-paas/api",
18
19
  "@gct-paas/core",
19
20
  "@gct-paas/core-mobile",
20
21
  "@gct-paas/core-web",
@@ -14,7 +14,7 @@ import fs from "fs-extra";
14
14
  import os from "os";
15
15
  import { copyFile, ignoreCompilerFile } from "../rollup-plugins/index.mjs";
16
16
  import { DEFAULT_EXTERNAL, PROD_MODE } from "../../constants/index.mjs";
17
- import { mergeConfig, winToUnixPath } from "../../util/index.mjs";
17
+ import { IS_NODE_MODULE, mergeConfig, winToUnixPath } from "../../util/index.mjs";
18
18
  export function defineRollupConfig(opts = {}) {
19
19
  process.on("SIGINT", () => {
20
20
  process.exit();
@@ -71,6 +71,7 @@ export function defineRollupConfig(opts = {}) {
71
71
  const output = [
72
72
  {
73
73
  dir: outDir,
74
+ esModule: true,
74
75
  format: "es",
75
76
  sourcemap: false,
76
77
  preserveModules: true,
@@ -82,7 +83,15 @@ export function defineRollupConfig(opts = {}) {
82
83
  defineConfig({
83
84
  input,
84
85
  treeshake: false,
85
- external: DEFAULT_EXTERNAL,
86
+ external: (id) => {
87
+ if (IS_NODE_MODULE.test(id)) {
88
+ return true;
89
+ }
90
+ if (DEFAULT_EXTERNAL.includes(id)) {
91
+ return true;
92
+ }
93
+ return false;
94
+ },
86
95
  output,
87
96
  plugins: [
88
97
  ignoreCompilerFile(externalCompileFileReg),
@@ -1,3 +1,4 @@
1
+ export { IS_NODE_MODULE } from './reg-exp/reg-exp';
1
2
  export { CopyWatch } from './watcher/watcher';
2
3
  /**
3
4
  * win 路径 \\ 转 linux 路径 /
package/es/util/index.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  import { mergeWith } from "lodash-es";
2
+ export { IS_NODE_MODULE } from "./reg-exp/reg-exp.mjs";
2
3
  export { CopyWatch } from "./watcher/watcher.mjs";
3
4
  export function winToUnixPath(pathStr) {
4
5
  return pathStr.replace(/\\/g, "/");
@@ -8,7 +9,7 @@ export function unixToWinPath(pathStr) {
8
9
  }
9
10
  export function mergeConfig(obj, obj2) {
10
11
  return mergeWith(obj, obj2, (objValue, srcValue) => {
11
- if (Array.isArray(objValue)) {
12
+ if (Array.isArray(objValue) && Array.isArray(srcValue)) {
12
13
  return objValue.concat(srcValue);
13
14
  }
14
15
  return void 0;
@@ -0,0 +1 @@
1
+ export declare const IS_NODE_MODULE: RegExp;
@@ -0,0 +1 @@
1
+ export const IS_NODE_MODULE = /node_modules\//;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * 项目自定义配置接口
3
+ *
4
+ * @author chitanda
5
+ * @date 2025-08-24 11:08:43
6
+ * @export
7
+ * @interface GctOpts
8
+ */
9
+ export interface GctOpts {
10
+ /**
11
+ * HTTP 代理配置,根据分支前缀匹配
12
+ *
13
+ * @author chitanda
14
+ * @date 2025-08-24 11:08:56
15
+ * @type {Record<string, string>}
16
+ */
17
+ httpProxyConfig: Record<string, string>;
18
+ }
File without changes
@@ -2,3 +2,4 @@ export { defineViteBaseConfig } from './vite-config/vite-base-config';
2
2
  export { defineViteConfig } from './vite-config/vite-config';
3
3
  export { defineDevViteConfig } from './vite-config/vite-dev-config';
4
4
  export { defineDesignPluginViteConfig, defineMobilePluginViteConfig, defineWebPluginViteConfig, } from './vite-config/vite-plugin-config';
5
+ export { defineProjectViteConfig } from './vite-config/vite-project-config';
package/es/vite/index.mjs CHANGED
@@ -6,3 +6,4 @@ export {
6
6
  defineMobilePluginViteConfig,
7
7
  defineWebPluginViteConfig
8
8
  } from "./vite-config/vite-plugin-config.mjs";
9
+ export { defineProjectViteConfig } from "./vite-config/vite-project-config.mjs";
@@ -0,0 +1,13 @@
1
+ import { UserConfig, UserConfigFnPromise } from 'vite';
2
+ import { GctOpts } from '../gct-opts.interface';
3
+ /**
4
+ * 构建本地开发 project 项目 vite 通用配置,基于此配置构建其他 vite 配置
5
+ * 参数合并时,数组会被合并而不是被替换
6
+ *
7
+ * @author chitanda
8
+ * @date 2025-08-24 11:08:04
9
+ * @export
10
+ * @param {UserConfig} [opts={}]
11
+ * @returns {*} {Promise<UserConfig>}
12
+ */
13
+ export declare function defineProjectViteConfig(gctOpts?: Partial<GctOpts>, opts?: UserConfig): UserConfigFnPromise;
@@ -0,0 +1,109 @@
1
+ import {
2
+ defineConfig
3
+ } from "vite";
4
+ import vue from "@vitejs/plugin-vue";
5
+ import vueJsx from "@vitejs/plugin-vue-jsx";
6
+ import legacy from "@vitejs/plugin-legacy";
7
+ import json from "@rollup/plugin-json";
8
+ import path from "path";
9
+ import fse from "fs-extra";
10
+ import { simpleGit } from "simple-git";
11
+ import { mergeConfig } from "../../util/index.mjs";
12
+ const gctOptsDefault = {
13
+ httpProxyConfig: {
14
+ alpha: "http://paas.alpha.gct-paas.com",
15
+ beta: "http://paas.beta.gct-paas.com",
16
+ "paas-ai-dev": "http://paas.aidev.gct-paas.com",
17
+ "paas-dev": "http://paas.paasdev.gct-paas.com",
18
+ "paas-test": "http://paas.paastest.gct-paas.com",
19
+ "mom-dev": "http://paas.momdev.gct-paas.com",
20
+ "mom-test": "http://paas.momtest.gct-paas.com",
21
+ "ncdp-dev": "http://paas.ncdpdev.gct-paas.com",
22
+ "ncdp-test": "http://paas.ncdptest.gct-paas.com",
23
+ "ipaas-dev": "http://paas.ipaasdev.gct-paas.com",
24
+ "ipaas-test": "http://paas.ipaastest.gct-paas.com",
25
+ "edhr-dev": "http://paas.edhrdev.gct-paas.com",
26
+ "edhr-test": "http://paas.edhrtest.gct-paas.com",
27
+ "datav-dev": "http://paas.datavdev.gct-paas.com"
28
+ }
29
+ };
30
+ export function defineProjectViteConfig(gctOpts = {}, opts = {}) {
31
+ const _gctOpts = mergeConfig(gctOptsDefault, gctOpts);
32
+ return defineConfig(async () => {
33
+ const cwd = process.cwd();
34
+ const pkg = fse.readJsonSync(path.resolve(cwd, "package.json"));
35
+ const git = simpleGit({ baseDir: cwd });
36
+ const branchSummary = await git.branch();
37
+ const httpProxyKey = Object.keys(_gctOpts.httpProxyConfig).find((key) => {
38
+ return key.startsWith(branchSummary.current);
39
+ }) || "paas-dev";
40
+ const httpProxy = _gctOpts.httpProxyConfig[httpProxyKey];
41
+ return mergeConfig(
42
+ {
43
+ resolve: {
44
+ alias: {
45
+ "@": path.resolve(cwd, "src")
46
+ }
47
+ },
48
+ build: {
49
+ rollupOptions: {
50
+ external: [
51
+ "core-js",
52
+ "vue",
53
+ "vue-i18n",
54
+ "vue-router",
55
+ "ant-design-vue",
56
+ "pinia",
57
+ "systemjs",
58
+ "@gct-paas/core",
59
+ "@gct-paas/core-web",
60
+ "@gct-paas/api"
61
+ ]
62
+ }
63
+ },
64
+ css: {
65
+ preprocessorOptions: {
66
+ scss: {
67
+ additionalData: `@use "@gct-paas/scss/style/global.scss" as *;`
68
+ }
69
+ }
70
+ },
71
+ server: {
72
+ host: "0.0.0.0",
73
+ cors: true,
74
+ fs: {
75
+ strict: false
76
+ },
77
+ proxy: {
78
+ hostname: "0.0.0.0",
79
+ ...["/gct-platform", "/gct-apaas", "/gct-ipaas", "/minio"].reduce(
80
+ (acc, item) => {
81
+ acc[item] = httpProxy;
82
+ return acc;
83
+ },
84
+ {}
85
+ )
86
+ }
87
+ },
88
+ define: {
89
+ "import.meta.env.pkg": {
90
+ name: pkg.name,
91
+ version: pkg.version
92
+ }
93
+ },
94
+ plugins: [
95
+ json(),
96
+ vue(),
97
+ vueJsx(),
98
+ legacy({
99
+ targets: ["chrome>=85", "edge>=85", "firefox>=79", "safari>=14.1"],
100
+ externalSystemJS: true,
101
+ // 关键配置:只生成 legacy 版本
102
+ renderModernChunks: false
103
+ })
104
+ ]
105
+ },
106
+ opts
107
+ );
108
+ });
109
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gct-paas/build",
3
- "version": "0.1.4-dev.3",
3
+ "version": "0.1.4-dev.5",
4
4
  "type": "module",
5
5
  "description": "paas 平台核心包",
6
6
  "main": "dist/index.cjs",
@@ -44,7 +44,7 @@
44
44
  "@commitlint/cli": "^19.8.1",
45
45
  "@commitlint/config-conventional": "^19.8.1",
46
46
  "@eslint/js": "^9.33.0",
47
- "@gct-paas/scss": "^0.1.4-dev.3",
47
+ "@gct-paas/scss": "^0.1.4-dev.5",
48
48
  "@inquirer/prompts": "^7.8.3",
49
49
  "@rollup/plugin-babel": "^6.0.4",
50
50
  "@rollup/plugin-commonjs": "^28.0.6",
@@ -52,6 +52,7 @@
52
52
  "@rollup/plugin-json": "^6.1.0",
53
53
  "@rollup/plugin-node-resolve": "^16.0.1",
54
54
  "@rollup/plugin-typescript": "^12.1.4",
55
+ "@vitejs/plugin-legacy": "^7.2.1",
55
56
  "@vitejs/plugin-vue": "^6.0.1",
56
57
  "@vitejs/plugin-vue-jsx": "^5.0.1",
57
58
  "@vue/compiler-sfc": "^3.5.18",
@@ -79,6 +80,7 @@
79
80
  "rimraf": "^6.0.1",
80
81
  "rollup": "^4.46.4",
81
82
  "rollup-plugin-esbuild": "^6.2.1",
83
+ "simple-git": "^3.28.0",
82
84
  "stylelint": "^16.23.1",
83
85
  "stylelint-config-standard-scss": "^15.0.1",
84
86
  "typescript-eslint": "^8.40.0",
@@ -98,5 +100,5 @@
98
100
  "typescript": "^5.9.2",
99
101
  "unbuild": "^3.6.1"
100
102
  },
101
- "gitHead": "caa65b07a6bbfb27d41911da2f5459567db38b1d"
103
+ "gitHead": "6fd4f6f4c3a0e1bd1fc4eea78fa9c2760e2219be"
102
104
  }