@gct-paas/build 0.1.4-dev.4 → 0.1.4-dev.6

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.
@@ -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';
@@ -7,7 +7,6 @@ exports.defineViteBaseConfig = defineViteBaseConfig;
7
7
  var _vite = require("vite");
8
8
  var _pluginVue = _interopRequireDefault(require("@vitejs/plugin-vue"));
9
9
  var _pluginVueJsx = _interopRequireDefault(require("@vitejs/plugin-vue-jsx"));
10
- var _pluginBabel = require("@rollup/plugin-babel");
11
10
  var _pluginJson = _interopRequireDefault(require("@rollup/plugin-json"));
12
11
  var _path = _interopRequireDefault(require("path"));
13
12
  var _constants = require("../../constants/index.cjs");
@@ -30,19 +29,27 @@ function defineViteBaseConfig(opts = {}) {
30
29
  external: _constants.DEFAULT_EXTERNAL
31
30
  }
32
31
  },
33
- plugins: [(0, _pluginJson.default)(), (0, _pluginVue.default)(), (0, _pluginVueJsx.default)(), (0, _pluginBabel.babel)({
34
- babelHelpers: "bundled",
35
- presets: [["@babel/preset-env", {
36
- useBuiltIns: "usage",
37
- corejs: 3,
38
- bugfixes: true,
39
- targets: {
40
- chrome: "85",
41
- edge: "85",
42
- firefox: "79",
43
- safari: "14.1"
44
- }
45
- }]]
46
- })]
32
+ plugins: [(0, _pluginJson.default)(), (0, _pluginVue.default)(), (0, _pluginVueJsx.default)()
33
+ // 关系 babel 配置,这个配置要放在具体的 project vite 编译配置中,底包应该是干净的
34
+ // babel({
35
+ // babelHelpers: 'bundled',
36
+ // presets: [
37
+ // [
38
+ // '@babel/preset-env',
39
+ // {
40
+ // useBuiltIns: false,
41
+ // corejs: 3,
42
+ // bugfixes: true,
43
+ // targets: {
44
+ // chrome: '85',
45
+ // edge: '85',
46
+ // firefox: '79',
47
+ // safari: '14.1',
48
+ // },
49
+ // },
50
+ // ],
51
+ // ],
52
+ // }),
53
+ ]
47
54
  }), opts);
48
55
  }
@@ -0,0 +1,95 @@
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
+ base: "./",
50
+ resolve: {
51
+ alias: {
52
+ "@": _path.default.resolve(cwd, "src")
53
+ }
54
+ },
55
+ build: {
56
+ rollupOptions: {
57
+ external: ["axios", "dayjs", "pinia", "lodash-es", "vue", "vue-i18n", "vue-router", "ant-design-vue", "pinia", "systemjs", "@gct-paas/core", "@gct-paas/core-web", "@gct-paas/api"]
58
+ }
59
+ },
60
+ css: {
61
+ preprocessorOptions: {
62
+ scss: {
63
+ additionalData: `@use "@gct-paas/scss/style/global.scss" as *;`
64
+ }
65
+ }
66
+ },
67
+ server: {
68
+ host: "0.0.0.0",
69
+ cors: true,
70
+ fs: {
71
+ strict: false
72
+ },
73
+ proxy: {
74
+ hostname: "0.0.0.0",
75
+ ...["/gct-platform", "/gct-apaas", "/gct-ipaas", "/minio"].reduce((acc, item) => {
76
+ acc[item] = httpProxy;
77
+ return acc;
78
+ }, {})
79
+ }
80
+ },
81
+ define: {
82
+ "import.meta.env.pkg": {
83
+ name: pkg.name,
84
+ version: pkg.version
85
+ }
86
+ },
87
+ plugins: [(0, _pluginJson.default)(), (0, _pluginVue.default)(), (0, _pluginVueJsx.default)(), (0, _pluginLegacy.default)({
88
+ targets: ["chrome>=85", "edge>=85", "firefox>=79", "safari>=14.1"],
89
+ externalSystemJS: true,
90
+ // 关键配置:只生成 legacy 版本
91
+ renderModernChunks: false
92
+ })]
93
+ }, opts);
94
+ });
95
+ }
@@ -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,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";
@@ -1,7 +1,6 @@
1
1
  import { defineConfig } from "vite";
2
2
  import vue from "@vitejs/plugin-vue";
3
3
  import vueJsx from "@vitejs/plugin-vue-jsx";
4
- import { babel } from "@rollup/plugin-babel";
5
4
  import json from "@rollup/plugin-json";
6
5
  import path from "path";
7
6
  import { DEFAULT_EXTERNAL } from "../../constants/index.mjs";
@@ -27,26 +26,27 @@ export function defineViteBaseConfig(opts = {}) {
27
26
  plugins: [
28
27
  json(),
29
28
  vue(),
30
- vueJsx(),
31
- babel({
32
- babelHelpers: "bundled",
33
- presets: [
34
- [
35
- "@babel/preset-env",
36
- {
37
- useBuiltIns: "usage",
38
- corejs: 3,
39
- bugfixes: true,
40
- targets: {
41
- chrome: "85",
42
- edge: "85",
43
- firefox: "79",
44
- safari: "14.1"
45
- }
46
- }
47
- ]
48
- ]
49
- })
29
+ vueJsx()
30
+ // 关系 babel 配置,这个配置要放在具体的 project vite 编译配置中,底包应该是干净的
31
+ // babel({
32
+ // babelHelpers: 'bundled',
33
+ // presets: [
34
+ // [
35
+ // '@babel/preset-env',
36
+ // {
37
+ // useBuiltIns: false,
38
+ // corejs: 3,
39
+ // bugfixes: true,
40
+ // targets: {
41
+ // chrome: '85',
42
+ // edge: '85',
43
+ // firefox: '79',
44
+ // safari: '14.1',
45
+ // },
46
+ // },
47
+ // ],
48
+ // ],
49
+ // }),
50
50
  ]
51
51
  }),
52
52
  opts
@@ -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,113 @@
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
+ base: "./",
44
+ resolve: {
45
+ alias: {
46
+ "@": path.resolve(cwd, "src")
47
+ }
48
+ },
49
+ build: {
50
+ rollupOptions: {
51
+ external: [
52
+ "axios",
53
+ "dayjs",
54
+ "pinia",
55
+ "lodash-es",
56
+ "vue",
57
+ "vue-i18n",
58
+ "vue-router",
59
+ "ant-design-vue",
60
+ "pinia",
61
+ "systemjs",
62
+ "@gct-paas/core",
63
+ "@gct-paas/core-web",
64
+ "@gct-paas/api"
65
+ ]
66
+ }
67
+ },
68
+ css: {
69
+ preprocessorOptions: {
70
+ scss: {
71
+ additionalData: `@use "@gct-paas/scss/style/global.scss" as *;`
72
+ }
73
+ }
74
+ },
75
+ server: {
76
+ host: "0.0.0.0",
77
+ cors: true,
78
+ fs: {
79
+ strict: false
80
+ },
81
+ proxy: {
82
+ hostname: "0.0.0.0",
83
+ ...["/gct-platform", "/gct-apaas", "/gct-ipaas", "/minio"].reduce(
84
+ (acc, item) => {
85
+ acc[item] = httpProxy;
86
+ return acc;
87
+ },
88
+ {}
89
+ )
90
+ }
91
+ },
92
+ define: {
93
+ "import.meta.env.pkg": {
94
+ name: pkg.name,
95
+ version: pkg.version
96
+ }
97
+ },
98
+ plugins: [
99
+ json(),
100
+ vue(),
101
+ vueJsx(),
102
+ legacy({
103
+ targets: ["chrome>=85", "edge>=85", "firefox>=79", "safari>=14.1"],
104
+ externalSystemJS: true,
105
+ // 关键配置:只生成 legacy 版本
106
+ renderModernChunks: false
107
+ })
108
+ ]
109
+ },
110
+ opts
111
+ );
112
+ });
113
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gct-paas/build",
3
- "version": "0.1.4-dev.4",
3
+ "version": "0.1.4-dev.6",
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.4",
47
+ "@gct-paas/scss": "^0.1.4-dev.6",
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": "8243f48a5c33973e9d610917555d9a3e27e6bd04"
103
+ "gitHead": "89142a76f256070c57ff8a6dcf062eba397f797a"
102
104
  }