@gct-paas/build 0.1.6-dev.4 → 0.1.6-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.
@@ -10,10 +10,10 @@ const DEFAULT_EXTERNAL = exports.DEFAULT_EXTERNAL = [
10
10
  // vue 相关依赖
11
11
  "vue", "vue-router", "vue-i18n", "pinia",
12
12
  // 第三方依赖
13
- "axios", "dayjs", "lodash-es", "qs", "bignumber.js", "wujie", "sql-formatter", "mqtt", "@fingerprintjs/fingerprintjs", "overlayscrollbars", "@jsplumb/browser-ui", "sortablejs", "interactjs",
13
+ "axios", "dayjs", "lodash-es", "qs", "bignumber.js", "wujie", "@module-federation/runtime", "sql-formatter", "mqtt", "@fingerprintjs/fingerprintjs", "overlayscrollbars", "@jsplumb/browser-ui", "sortablejs", "interactjs", "bwip-js",
14
14
  // 组件库相关依赖
15
- "vuedraggable", "vue-grid-layout", "vant", "ant-design-vue",
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
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/formula-editor", "@gct-paas/platform-icons"];
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"];
@@ -7,7 +7,7 @@ exports.defineStylelintConfig = defineStylelintConfig;
7
7
  var _lodashEs = require("lodash-es");
8
8
  function defineStylelintConfig(config = {}) {
9
9
  return (0, _lodashEs.merge)({
10
- extends: ["stylelint-config-standard", "stylelint-config-standard-scss"],
10
+ extends: ["stylelint-config-standard-scss", "stylelint-config-recess-order"],
11
11
  rules: {
12
12
  "annotation-no-unknown": null,
13
13
  "color-no-invalid-hex": true,
@@ -27,12 +27,24 @@ Object.defineProperty(exports, "defineMobilePluginViteConfig", {
27
27
  return _vitePluginConfig.defineMobilePluginViteConfig;
28
28
  }
29
29
  });
30
+ Object.defineProperty(exports, "definePadPluginViteConfig", {
31
+ enumerable: true,
32
+ get: function () {
33
+ return _vitePluginConfig.definePadPluginViteConfig;
34
+ }
35
+ });
30
36
  Object.defineProperty(exports, "definePkgDevViteConfig", {
31
37
  enumerable: true,
32
38
  get: function () {
33
39
  return _vitePkgDevConfig.definePkgDevViteConfig;
34
40
  }
35
41
  });
42
+ Object.defineProperty(exports, "definePluginViteConfig", {
43
+ enumerable: true,
44
+ get: function () {
45
+ return _vitePluginConfig.definePluginViteConfig;
46
+ }
47
+ });
36
48
  Object.defineProperty(exports, "defineProjectViteConfig", {
37
49
  enumerable: true,
38
50
  get: function () {
@@ -2,5 +2,5 @@ export { defineViteBaseConfig } from './vite-config/vite-base-config';
2
2
  export { defineViteConfig, defineLoaderViteConfig } from './vite-config/vite-config';
3
3
  export { defineDevViteConfig } from './vite-config/vite-dev-config';
4
4
  export { definePkgDevViteConfig } from './vite-config/vite-pkg-dev-config';
5
- export { defineDesignPluginViteConfig, defineMobilePluginViteConfig, defineWebPluginViteConfig, } from './vite-config/vite-plugin-config';
5
+ export { definePluginViteConfig, defineDesignPluginViteConfig, defineMobilePluginViteConfig, definePadPluginViteConfig, defineWebPluginViteConfig, } from './vite-config/vite-plugin-config';
6
6
  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 _vite2 = _interopRequireDefault(require("unocss/vite"));
11
10
  var _path = _interopRequireDefault(require("path"));
12
11
  var _constants = require("../../constants/index.cjs");
13
12
  var _util = require("../../util/index.cjs");
@@ -16,6 +15,11 @@ function defineViteBaseConfig(opts = {}) {
16
15
  const cwd = process.cwd();
17
16
  const outDir = _path.default.resolve(cwd, "dist");
18
17
  return (0, _util.mergeConfig)((0, _vite.defineConfig)({
18
+ resolve: {
19
+ alias: {
20
+ "@": _path.default.resolve(cwd, "./src")
21
+ }
22
+ },
19
23
  css: {
20
24
  preprocessorOptions: {
21
25
  scss: {
@@ -25,12 +29,11 @@ function defineViteBaseConfig(opts = {}) {
25
29
  },
26
30
  build: {
27
31
  outDir,
32
+ target: "chrome89",
28
33
  rolldownOptions: {
29
34
  external: _constants.DEFAULT_EXTERNAL
30
35
  }
31
36
  },
32
- plugins: [(0, _pluginVue.default)(), (0, _pluginVueJsx.default)(), (0, _vite2.default)({
33
- hmrTopLevelAwait: false
34
- })]
37
+ plugins: [(0, _pluginVue.default)(), (0, _pluginVueJsx.default)()]
35
38
  }), opts);
36
39
  }
@@ -7,38 +7,42 @@ exports.defineLoaderViteConfig = defineLoaderViteConfig;
7
7
  exports.defineViteConfig = defineViteConfig;
8
8
  var _vite = require("vite");
9
9
  var _path = _interopRequireDefault(require("path"));
10
- var rf = _interopRequireWildcard(require("rimraf"));
10
+ var _vite2 = _interopRequireDefault(require("unocss/vite"));
11
11
  var _viteBaseConfig = require("./vite-base-config.cjs");
12
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
13
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
14
12
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
13
  function defineViteConfig(opts = {}) {
16
14
  const cwd = process.cwd();
17
- const outDir = _path.default.resolve(cwd, "dist");
18
- rf.sync(outDir);
19
15
  return (0, _vite.mergeConfig)((0, _viteBaseConfig.defineViteBaseConfig)((0, _vite.defineConfig)({
20
16
  build: {
17
+ minify: "terser",
18
+ terserOptions: {
19
+ compress: {
20
+ drop_console: false,
21
+ dead_code: true,
22
+ unused: true,
23
+ passes: 2
24
+ },
25
+ mangle: true
26
+ },
21
27
  lib: {
22
28
  entry: _path.default.resolve(cwd, "src/index.ts"),
23
29
  formats: ["es"],
24
30
  cssFileName: "index.min",
25
31
  fileName: "[name].[format].min"
26
32
  }
27
- }
33
+ },
34
+ plugins: [(0, _vite2.default)({
35
+ hmrTopLevelAwait: false
36
+ })]
28
37
  })), opts);
29
38
  }
30
39
  function defineLoaderViteConfig(opts = {}) {
31
40
  const cwd = process.cwd();
32
- const outDir = _path.default.resolve(cwd, "dist");
33
- rf.sync(outDir);
34
- return (0, _vite.mergeConfig)((0, _viteBaseConfig.defineViteBaseConfig)((0, _vite.defineConfig)({
41
+ return (0, _vite.mergeConfig)(defineViteConfig({
35
42
  build: {
36
43
  lib: {
37
- entry: _path.default.resolve(cwd, "src/loader.ts"),
38
- formats: ["es"],
39
- cssFileName: "index.min",
40
- fileName: "[name].[format].min"
44
+ entry: _path.default.resolve(cwd, "src/loader.ts")
41
45
  }
42
46
  }
43
- })), opts);
47
+ }), opts);
44
48
  }
@@ -7,4 +7,11 @@ import { UserConfig } from 'vite';
7
7
  * @returns {*} {UserConfig}
8
8
  */
9
9
  export declare function defineViteConfig(opts?: UserConfig): UserConfig;
10
+ /**
11
+ * 构建 loader 模块的 vite 配置,基于此配置构建基于 index 模式下的上层样式加载封装
12
+ *
13
+ * @export
14
+ * @param {UserConfig} [opts={}]
15
+ * @return {*} {UserConfig}
16
+ */
10
17
  export declare function defineLoaderViteConfig(opts?: UserConfig): UserConfig;
@@ -5,87 +5,78 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.defineDesignPluginViteConfig = defineDesignPluginViteConfig;
7
7
  exports.defineMobilePluginViteConfig = defineMobilePluginViteConfig;
8
+ exports.definePadPluginViteConfig = definePadPluginViteConfig;
9
+ exports.definePluginViteConfig = definePluginViteConfig;
8
10
  exports.defineWebPluginViteConfig = defineWebPluginViteConfig;
9
11
  var _vite = require("vite");
10
12
  var _path = _interopRequireDefault(require("path"));
11
13
  var _viteBaseConfig = require("./vite-base-config.cjs");
14
+ var _constants = require("../../constants/index.cjs");
15
+ var _imnportExternalPlugin = require("../vite-plugins/imnport-external-plugin.cjs");
12
16
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
- const formats = ["cjs", "es"];
14
- function formatFileName(format) {
15
- return `[name].${format}.min.js`;
16
- }
17
- function assetFileNames(assetInfo, name) {
18
- if (assetInfo.names.length > 0 && assetInfo.names[0].endsWith(".css")) {
19
- return name + ".min.css";
20
- }
21
- return assetInfo.names[0];
22
- }
23
- function defineDesignPluginViteConfig(opts = {}) {
17
+ function definePluginViteConfig(opts = {}) {
24
18
  const cwd = process.cwd();
25
- const designEntry = _path.default.resolve(cwd, "src/index.ts");
19
+ const entry = _path.default.resolve(cwd, "src/index.ts");
20
+ const loaderEntry = _path.default.resolve(cwd, "src/loader.ts");
21
+ const isProd = process.env.NODE_ENV === "production";
26
22
  return (0, _vite.mergeConfig)((0, _viteBaseConfig.defineViteBaseConfig)({
23
+ optimizeDeps: {
24
+ exclude: _constants.DEFAULT_EXTERNAL
25
+ },
27
26
  build: {
28
- emptyOutDir: false,
29
- rolldownOptions: {
30
- output: {
31
- assetFileNames: assetInfo => {
32
- return assetFileNames(assetInfo, "design");
33
- }
34
- }
35
- },
36
27
  lib: {
37
- entry: {
38
- design: designEntry
39
- },
40
- formats,
41
- fileName: formatFileName
28
+ entry: isProd ? loaderEntry : entry,
29
+ formats: ["es"],
30
+ cssFileName: "index.min",
31
+ fileName: "[name].[format].min"
42
32
  }
33
+ },
34
+ plugins: [...(0, _imnportExternalPlugin.importMapExternalPlugin)(_constants.DEFAULT_EXTERNAL)
35
+ // federation({
36
+ // name: 'gct-paas-plugin',
37
+ // filename: 'remoteEntry.js',
38
+ // dts: false,
39
+ // manifest: true,
40
+ // exposes: {
41
+ // '.': './src/index.ts',
42
+ // },
43
+ // }),
44
+ ]
45
+ }), opts);
46
+ }
47
+ function defineDesignPluginViteConfig(opts = {}) {
48
+ return (0, _vite.mergeConfig)(definePluginViteConfig({
49
+ server: {
50
+ port: 7001,
51
+ host: "0.0.0.0",
52
+ allowedHosts: true
43
53
  }
44
54
  }), opts);
45
55
  }
46
56
  function defineMobilePluginViteConfig(opts = {}) {
47
- const cwd = process.cwd();
48
- const mobileEntry = _path.default.resolve(cwd, "src/index.ts");
49
- return (0, _vite.mergeConfig)((0, _viteBaseConfig.defineViteBaseConfig)({
50
- build: {
51
- emptyOutDir: false,
52
- rolldownOptions: {
53
- output: {
54
- assetFileNames: assetInfo => {
55
- return assetFileNames(assetInfo, "mobile");
56
- }
57
- }
58
- },
59
- lib: {
60
- entry: {
61
- mobile: mobileEntry
62
- },
63
- formats,
64
- fileName: formatFileName
65
- }
57
+ return (0, _vite.mergeConfig)(definePluginViteConfig({
58
+ server: {
59
+ port: 7002,
60
+ host: "0.0.0.0",
61
+ allowedHosts: true
62
+ }
63
+ }), opts);
64
+ }
65
+ function definePadPluginViteConfig(opts = {}) {
66
+ return (0, _vite.mergeConfig)(definePluginViteConfig({
67
+ server: {
68
+ port: 7003,
69
+ host: "0.0.0.0",
70
+ allowedHosts: true
66
71
  }
67
72
  }), opts);
68
73
  }
69
74
  function defineWebPluginViteConfig(opts = {}) {
70
- const cwd = process.cwd();
71
- const webEntry = _path.default.resolve(cwd, "src/index.ts");
72
- return (0, _vite.mergeConfig)((0, _viteBaseConfig.defineViteBaseConfig)({
73
- build: {
74
- emptyOutDir: false,
75
- rolldownOptions: {
76
- output: {
77
- assetFileNames: assetInfo => {
78
- return assetFileNames(assetInfo, "web");
79
- }
80
- }
81
- },
82
- lib: {
83
- entry: {
84
- web: webEntry
85
- },
86
- formats,
87
- fileName: formatFileName
88
- }
75
+ return (0, _vite.mergeConfig)(definePluginViteConfig({
76
+ server: {
77
+ port: 7004,
78
+ host: "0.0.0.0",
79
+ allowedHosts: true
89
80
  }
90
81
  }), opts);
91
82
  }
@@ -1,25 +1,41 @@
1
1
  import { UserConfig } from 'vite';
2
2
  /**
3
- * 设计端构建配置
3
+ * 插件构建配置
4
4
  *
5
5
  * @export
6
6
  * @param {UserConfig} [opts={}]
7
- * @returns {*} {UserConfig}
7
+ * @return {*} {UserConfig}
8
+ */
9
+ export declare function definePluginViteConfig(opts?: UserConfig): UserConfig;
10
+ /**
11
+ * 设计界面插件构建配置
12
+ *
13
+ * @export
14
+ * @param {UserConfig} [opts={}]
15
+ * @return {*} {UserConfig}
8
16
  */
9
17
  export declare function defineDesignPluginViteConfig(opts?: UserConfig): UserConfig;
10
18
  /**
11
- * 移动端插件构建配置
19
+ * 设计界面插件构建配置
12
20
  *
13
21
  * @export
14
22
  * @param {UserConfig} [opts={}]
15
- * @returns {*} {UserConfig}
23
+ * @return {*} {UserConfig}
16
24
  */
17
25
  export declare function defineMobilePluginViteConfig(opts?: UserConfig): UserConfig;
18
26
  /**
19
- * 网页端插件构建配置
27
+ * 设计界面插件构建配置
28
+ *
29
+ * @export
30
+ * @param {UserConfig} [opts={}]
31
+ * @return {*} {UserConfig}
32
+ */
33
+ export declare function definePadPluginViteConfig(opts?: UserConfig): UserConfig;
34
+ /**
35
+ * 设计界面插件构建配置
20
36
  *
21
37
  * @export
22
38
  * @param {UserConfig} [opts={}]
23
- * @returns {*} {UserConfig}
39
+ * @return {*} {UserConfig}
24
40
  */
25
41
  export declare function defineWebPluginViteConfig(opts?: UserConfig): UserConfig;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.importMapExternalPlugin = importMapExternalPlugin;
7
+ function importMapExternalPlugin(modules) {
8
+ return [{
9
+ name: "gct-vite-plugin:import-external",
10
+ apply: "serve",
11
+ enforce: "pre",
12
+ resolveId(id) {
13
+ if (modules.includes(id)) {
14
+ return {
15
+ id,
16
+ external: true
17
+ };
18
+ }
19
+ }
20
+ }];
21
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * 在 dev 模式下:告诉 Rollup/Rolldown 指定模块是 external
3
+ *
4
+ * @export
5
+ * @param {string[]} modules
6
+ * @return {*}
7
+ */
8
+ export declare function importMapExternalPlugin(modules: string[]): {
9
+ name: string;
10
+ apply: "serve";
11
+ enforce: "pre";
12
+ resolveId(id: string): {
13
+ id: string;
14
+ external: boolean;
15
+ } | undefined;
16
+ }[];
@@ -13,6 +13,7 @@ export const DEFAULT_EXTERNAL = [
13
13
  "qs",
14
14
  "bignumber.js",
15
15
  "wujie",
16
+ "@module-federation/runtime",
16
17
  "sql-formatter",
17
18
  "mqtt",
18
19
  "@fingerprintjs/fingerprintjs",
@@ -20,11 +21,13 @@ export const DEFAULT_EXTERNAL = [
20
21
  "@jsplumb/browser-ui",
21
22
  "sortablejs",
22
23
  "interactjs",
24
+ "bwip-js",
23
25
  // 组件库相关依赖
24
26
  "vuedraggable",
25
27
  "vue-grid-layout",
26
28
  "vant",
27
29
  "ant-design-vue",
30
+ "vxe-table",
28
31
  // 图标库相关依赖
29
32
  "@ant-design/icons-vue",
30
33
  "@icon-park/vue-next/es/all",
@@ -45,6 +48,6 @@ export const DEFAULT_EXTERNAL = [
45
48
  "@gct-paas/render-web",
46
49
  "@gct-paas/schema",
47
50
  "@gct-paas/scss",
48
- "@gct-paas/formula-editor",
49
- "@gct-paas/platform-icons"
51
+ "@gct-paas/platform-icons",
52
+ "@gct-paas/vue-pdf"
50
53
  ];
@@ -2,7 +2,10 @@ import { merge } from "lodash-es";
2
2
  export function defineStylelintConfig(config = {}) {
3
3
  return merge(
4
4
  {
5
- extends: ["stylelint-config-standard", "stylelint-config-standard-scss"],
5
+ extends: [
6
+ "stylelint-config-standard-scss",
7
+ "stylelint-config-recess-order"
8
+ ],
6
9
  rules: {
7
10
  "annotation-no-unknown": null,
8
11
  "color-no-invalid-hex": true,
@@ -2,5 +2,5 @@ export { defineViteBaseConfig } from './vite-config/vite-base-config';
2
2
  export { defineViteConfig, defineLoaderViteConfig } from './vite-config/vite-config';
3
3
  export { defineDevViteConfig } from './vite-config/vite-dev-config';
4
4
  export { definePkgDevViteConfig } from './vite-config/vite-pkg-dev-config';
5
- export { defineDesignPluginViteConfig, defineMobilePluginViteConfig, defineWebPluginViteConfig, } from './vite-config/vite-plugin-config';
5
+ export { definePluginViteConfig, defineDesignPluginViteConfig, defineMobilePluginViteConfig, definePadPluginViteConfig, defineWebPluginViteConfig, } from './vite-config/vite-plugin-config';
6
6
  export { defineProjectViteConfig } from './vite-config/vite-project-config';
package/es/vite/index.mjs CHANGED
@@ -3,8 +3,10 @@ export { defineViteConfig, defineLoaderViteConfig } from "./vite-config/vite-con
3
3
  export { defineDevViteConfig } from "./vite-config/vite-dev-config.mjs";
4
4
  export { definePkgDevViteConfig } from "./vite-config/vite-pkg-dev-config.mjs";
5
5
  export {
6
+ definePluginViteConfig,
6
7
  defineDesignPluginViteConfig,
7
8
  defineMobilePluginViteConfig,
9
+ definePadPluginViteConfig,
8
10
  defineWebPluginViteConfig
9
11
  } from "./vite-config/vite-plugin-config.mjs";
10
12
  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 UnoCSS from "unocss/vite";
5
4
  import path from "path";
6
5
  import { DEFAULT_EXTERNAL } from "../../constants/index.mjs";
7
6
  import { mergeConfig } from "../../util/index.mjs";
@@ -10,6 +9,11 @@ export function defineViteBaseConfig(opts = {}) {
10
9
  const outDir = path.resolve(cwd, "dist");
11
10
  return mergeConfig(
12
11
  defineConfig({
12
+ resolve: {
13
+ alias: {
14
+ "@": path.resolve(cwd, "./src")
15
+ }
16
+ },
13
17
  css: {
14
18
  preprocessorOptions: {
15
19
  scss: {
@@ -19,14 +23,14 @@ export function defineViteBaseConfig(opts = {}) {
19
23
  },
20
24
  build: {
21
25
  outDir,
26
+ target: "chrome89",
22
27
  rolldownOptions: {
23
28
  external: DEFAULT_EXTERNAL
24
29
  }
25
30
  },
26
31
  plugins: [
27
32
  vue(),
28
- vueJsx(),
29
- UnoCSS({ hmrTopLevelAwait: false })
33
+ vueJsx()
30
34
  ]
31
35
  }),
32
36
  opts
@@ -7,4 +7,11 @@ import { UserConfig } from 'vite';
7
7
  * @returns {*} {UserConfig}
8
8
  */
9
9
  export declare function defineViteConfig(opts?: UserConfig): UserConfig;
10
+ /**
11
+ * 构建 loader 模块的 vite 配置,基于此配置构建基于 index 模式下的上层样式加载封装
12
+ *
13
+ * @export
14
+ * @param {UserConfig} [opts={}]
15
+ * @return {*} {UserConfig}
16
+ */
10
17
  export declare function defineLoaderViteConfig(opts?: UserConfig): UserConfig;
@@ -1,22 +1,33 @@
1
1
  import { defineConfig, mergeConfig } from "vite";
2
2
  import path from "path";
3
- import * as rf from "rimraf";
3
+ import UnoCSS from "unocss/vite";
4
4
  import { defineViteBaseConfig } from "./vite-base-config.mjs";
5
5
  export function defineViteConfig(opts = {}) {
6
6
  const cwd = process.cwd();
7
- const outDir = path.resolve(cwd, "dist");
8
- rf.sync(outDir);
9
7
  return mergeConfig(
10
8
  defineViteBaseConfig(
11
9
  defineConfig({
12
10
  build: {
11
+ minify: "terser",
12
+ terserOptions: {
13
+ compress: {
14
+ drop_console: false,
15
+ dead_code: true,
16
+ unused: true,
17
+ passes: 2
18
+ },
19
+ mangle: true
20
+ },
13
21
  lib: {
14
22
  entry: path.resolve(cwd, "src/index.ts"),
15
23
  formats: ["es"],
16
24
  cssFileName: "index.min",
17
25
  fileName: "[name].[format].min"
18
26
  }
19
- }
27
+ },
28
+ plugins: [
29
+ UnoCSS({ hmrTopLevelAwait: false })
30
+ ]
20
31
  })
21
32
  ),
22
33
  opts
@@ -24,21 +35,14 @@ export function defineViteConfig(opts = {}) {
24
35
  }
25
36
  export function defineLoaderViteConfig(opts = {}) {
26
37
  const cwd = process.cwd();
27
- const outDir = path.resolve(cwd, "dist");
28
- rf.sync(outDir);
29
38
  return mergeConfig(
30
- defineViteBaseConfig(
31
- defineConfig({
32
- build: {
33
- lib: {
34
- entry: path.resolve(cwd, "src/loader.ts"),
35
- formats: ["es"],
36
- cssFileName: "index.min",
37
- fileName: "[name].[format].min"
38
- }
39
+ defineViteConfig({
40
+ build: {
41
+ lib: {
42
+ entry: path.resolve(cwd, "src/loader.ts")
39
43
  }
40
- })
41
- ),
44
+ }
45
+ }),
42
46
  opts
43
47
  );
44
48
  }
@@ -1,25 +1,41 @@
1
1
  import { UserConfig } from 'vite';
2
2
  /**
3
- * 设计端构建配置
3
+ * 插件构建配置
4
4
  *
5
5
  * @export
6
6
  * @param {UserConfig} [opts={}]
7
- * @returns {*} {UserConfig}
7
+ * @return {*} {UserConfig}
8
+ */
9
+ export declare function definePluginViteConfig(opts?: UserConfig): UserConfig;
10
+ /**
11
+ * 设计界面插件构建配置
12
+ *
13
+ * @export
14
+ * @param {UserConfig} [opts={}]
15
+ * @return {*} {UserConfig}
8
16
  */
9
17
  export declare function defineDesignPluginViteConfig(opts?: UserConfig): UserConfig;
10
18
  /**
11
- * 移动端插件构建配置
19
+ * 设计界面插件构建配置
12
20
  *
13
21
  * @export
14
22
  * @param {UserConfig} [opts={}]
15
- * @returns {*} {UserConfig}
23
+ * @return {*} {UserConfig}
16
24
  */
17
25
  export declare function defineMobilePluginViteConfig(opts?: UserConfig): UserConfig;
18
26
  /**
19
- * 网页端插件构建配置
27
+ * 设计界面插件构建配置
28
+ *
29
+ * @export
30
+ * @param {UserConfig} [opts={}]
31
+ * @return {*} {UserConfig}
32
+ */
33
+ export declare function definePadPluginViteConfig(opts?: UserConfig): UserConfig;
34
+ /**
35
+ * 设计界面插件构建配置
20
36
  *
21
37
  * @export
22
38
  * @param {UserConfig} [opts={}]
23
- * @returns {*} {UserConfig}
39
+ * @return {*} {UserConfig}
24
40
  */
25
41
  export declare function defineWebPluginViteConfig(opts?: UserConfig): UserConfig;
@@ -1,89 +1,85 @@
1
1
  import { mergeConfig } from "vite";
2
2
  import path from "path";
3
3
  import { defineViteBaseConfig } from "./vite-base-config.mjs";
4
- const formats = ["cjs", "es"];
5
- function formatFileName(format) {
6
- return `[name].${format}.min.js`;
7
- }
8
- function assetFileNames(assetInfo, name) {
9
- if (assetInfo.names.length > 0 && assetInfo.names[0].endsWith(".css")) {
10
- return name + ".min.css";
11
- }
12
- return assetInfo.names[0];
13
- }
14
- export function defineDesignPluginViteConfig(opts = {}) {
4
+ import { DEFAULT_EXTERNAL } from "../../constants/index.mjs";
5
+ import { importMapExternalPlugin } from "../vite-plugins/imnport-external-plugin.mjs";
6
+ export function definePluginViteConfig(opts = {}) {
15
7
  const cwd = process.cwd();
16
- const designEntry = path.resolve(cwd, "src/index.ts");
8
+ const entry = path.resolve(cwd, "src/index.ts");
9
+ const loaderEntry = path.resolve(cwd, "src/loader.ts");
10
+ const isProd = process.env.NODE_ENV === "production";
17
11
  return mergeConfig(
18
12
  defineViteBaseConfig({
13
+ optimizeDeps: {
14
+ exclude: DEFAULT_EXTERNAL
15
+ },
19
16
  build: {
20
- emptyOutDir: false,
21
- rolldownOptions: {
22
- output: {
23
- assetFileNames: (assetInfo) => {
24
- return assetFileNames(assetInfo, "design");
25
- }
26
- }
27
- },
28
17
  lib: {
29
- entry: {
30
- design: designEntry
31
- },
32
- formats,
33
- fileName: formatFileName
18
+ entry: isProd ? loaderEntry : entry,
19
+ formats: ["es"],
20
+ cssFileName: "index.min",
21
+ fileName: "[name].[format].min"
34
22
  }
23
+ },
24
+ plugins: [
25
+ ...importMapExternalPlugin(DEFAULT_EXTERNAL)
26
+ // federation({
27
+ // name: 'gct-paas-plugin',
28
+ // filename: 'remoteEntry.js',
29
+ // dts: false,
30
+ // manifest: true,
31
+ // exposes: {
32
+ // '.': './src/index.ts',
33
+ // },
34
+ // }),
35
+ ]
36
+ }),
37
+ opts
38
+ );
39
+ }
40
+ export function defineDesignPluginViteConfig(opts = {}) {
41
+ return mergeConfig(
42
+ definePluginViteConfig({
43
+ server: {
44
+ port: 7001,
45
+ host: "0.0.0.0",
46
+ allowedHosts: true
35
47
  }
36
48
  }),
37
49
  opts
38
50
  );
39
51
  }
40
52
  export function defineMobilePluginViteConfig(opts = {}) {
41
- const cwd = process.cwd();
42
- const mobileEntry = path.resolve(cwd, "src/index.ts");
43
53
  return mergeConfig(
44
- defineViteBaseConfig({
45
- build: {
46
- emptyOutDir: false,
47
- rolldownOptions: {
48
- output: {
49
- assetFileNames: (assetInfo) => {
50
- return assetFileNames(assetInfo, "mobile");
51
- }
52
- }
53
- },
54
- lib: {
55
- entry: {
56
- mobile: mobileEntry
57
- },
58
- formats,
59
- fileName: formatFileName
60
- }
54
+ definePluginViteConfig({
55
+ server: {
56
+ port: 7002,
57
+ host: "0.0.0.0",
58
+ allowedHosts: true
59
+ }
60
+ }),
61
+ opts
62
+ );
63
+ }
64
+ export function definePadPluginViteConfig(opts = {}) {
65
+ return mergeConfig(
66
+ definePluginViteConfig({
67
+ server: {
68
+ port: 7003,
69
+ host: "0.0.0.0",
70
+ allowedHosts: true
61
71
  }
62
72
  }),
63
73
  opts
64
74
  );
65
75
  }
66
76
  export function defineWebPluginViteConfig(opts = {}) {
67
- const cwd = process.cwd();
68
- const webEntry = path.resolve(cwd, "src/index.ts");
69
77
  return mergeConfig(
70
- defineViteBaseConfig({
71
- build: {
72
- emptyOutDir: false,
73
- rolldownOptions: {
74
- output: {
75
- assetFileNames: (assetInfo) => {
76
- return assetFileNames(assetInfo, "web");
77
- }
78
- }
79
- },
80
- lib: {
81
- entry: {
82
- web: webEntry
83
- },
84
- formats,
85
- fileName: formatFileName
86
- }
78
+ definePluginViteConfig({
79
+ server: {
80
+ port: 7004,
81
+ host: "0.0.0.0",
82
+ allowedHosts: true
87
83
  }
88
84
  }),
89
85
  opts
@@ -0,0 +1,16 @@
1
+ /**
2
+ * 在 dev 模式下:告诉 Rollup/Rolldown 指定模块是 external
3
+ *
4
+ * @export
5
+ * @param {string[]} modules
6
+ * @return {*}
7
+ */
8
+ export declare function importMapExternalPlugin(modules: string[]): {
9
+ name: string;
10
+ apply: "serve";
11
+ enforce: "pre";
12
+ resolveId(id: string): {
13
+ id: string;
14
+ external: boolean;
15
+ } | undefined;
16
+ }[];
@@ -0,0 +1,14 @@
1
+ export function importMapExternalPlugin(modules) {
2
+ return [
3
+ {
4
+ name: "gct-vite-plugin:import-external",
5
+ apply: "serve",
6
+ enforce: "pre",
7
+ resolveId(id) {
8
+ if (modules.includes(id)) {
9
+ return { id, external: true };
10
+ }
11
+ }
12
+ }
13
+ ];
14
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gct-paas/build",
3
- "version": "0.1.6-dev.4",
3
+ "version": "0.1.6-dev.6",
4
4
  "type": "module",
5
5
  "description": "paas 平台核心包",
6
6
  "main": "dist/index.cjs",
@@ -43,7 +43,7 @@
43
43
  "@commitlint/config-conventional": "^20.4.4",
44
44
  "@eslint/config-helpers": "^0.5.3",
45
45
  "@eslint/js": "^9.39.4",
46
- "@gct-paas/scss": "^0.1.5",
46
+ "@gct-paas/scss": "latest",
47
47
  "@inquirer/prompts": "^8.3.0",
48
48
  "@module-federation/vite": "^1.13.0",
49
49
  "@vitejs/plugin-vue": "^6.0.5",
@@ -71,16 +71,18 @@
71
71
  "prettier": "^3.8.1",
72
72
  "rimraf": "^6.1.3",
73
73
  "sass": "^1.98.0",
74
- "stylelint": "^17.4.0",
75
- "stylelint-config-standard-scss": "^17.0.0",
74
+ "stylelint": "~16.26.1",
75
+ "stylelint-config-recess-order": "~7.4.0",
76
+ "stylelint-config-standard-scss": "~16.0.0",
77
+ "stylelint-scss": "~6.14.0",
76
78
  "typescript-eslint": "^8.57.0",
77
79
  "unocss": "66.6.6",
78
- "vite": "^8.0.0",
80
+ "vite": "^8.0.1",
79
81
  "vite-plugin-dts": "^4.5.4",
80
82
  "vite-plugin-lib-inject-css": "^2.2.2",
81
83
  "vite-plugin-static-copy": "^3.3.0",
82
84
  "vue-eslint-parser": "^10.4.0",
83
- "vue-tsc": "^3.2.5"
85
+ "vue-tsc": "^3.2.6"
84
86
  },
85
87
  "devDependencies": {
86
88
  "@commitlint/types": "^20.4.4",
@@ -94,5 +96,8 @@
94
96
  "typescript": "^5.9.3",
95
97
  "unbuild": "^3.6.1"
96
98
  },
97
- "gitHead": "82bbd8e79ae2d255a7ccd03f2e0492dabec7fee5"
99
+ "peerDependencies": {
100
+ "@gct-paas/scss": "*"
101
+ },
102
+ "gitHead": "2e48c22f823afd42f491f0df915aeca837964f19"
98
103
  }