@gct-paas/build 0.1.5-dev.9 → 0.1.6-dev.10
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/constants/index.cjs +14 -3
- package/dist/constants/index.d.ts +0 -4
- package/dist/eslint/eslint-config/eslint-config.cjs +14 -1
- package/dist/index.cjs +11 -11
- package/dist/index.d.ts +1 -1
- package/dist/stylelint/stylelint-config/stylelint-config.cjs +1 -1
- package/dist/util/env-state/env-state.cjs +9 -0
- package/dist/util/env-state/env-state.d.ts +7 -0
- package/dist/util/index.cjs +7 -0
- package/dist/util/index.d.ts +1 -0
- package/dist/vite/index.cjs +18 -0
- package/dist/vite/index.d.ts +2 -2
- package/dist/vite/vite-config/vite-base-config.cjs +8 -27
- package/dist/vite/vite-config/vite-config.cjs +33 -23
- package/dist/vite/vite-config/vite-config.d.ts +8 -0
- package/dist/vite/vite-config/vite-dev-config.cjs +1 -2
- package/dist/vite/vite-config/vite-pkg-dev-config.cjs +6 -8
- package/dist/vite/vite-config/vite-plugin-config.cjs +69 -71
- package/dist/vite/vite-config/vite-plugin-config.d.ts +22 -6
- package/dist/vite/vite-config/vite-project-config.cjs +9 -45
- package/dist/vite/vite-config/vite-project-config.d.ts +1 -2
- package/dist/vite/vite-plugins/imnport-external-plugin.cjs +21 -0
- package/dist/vite/vite-plugins/imnport-external-plugin.d.ts +16 -0
- package/dist/vite/vite-plugins/inject-importmap-plugin.cjs +94 -0
- package/dist/vite/vite-plugins/inject-importmap-plugin.d.ts +19 -0
- package/es/constants/index.d.ts +0 -4
- package/es/constants/index.mjs +35 -8
- package/es/eslint/eslint-config/eslint-config.mjs +21 -1
- package/es/index.d.ts +1 -1
- package/es/index.mjs +1 -1
- package/es/stylelint/stylelint-config/stylelint-config.mjs +4 -1
- package/es/util/env-state/env-state.d.ts +7 -0
- package/es/util/env-state/env-state.mjs +3 -0
- package/es/util/index.d.ts +1 -0
- package/es/util/index.mjs +1 -0
- package/es/vite/index.d.ts +2 -2
- package/es/vite/index.mjs +3 -1
- package/es/vite/vite-config/vite-base-config.mjs +8 -26
- package/es/vite/vite-config/vite-config.d.ts +8 -0
- package/es/vite/vite-config/vite-config.mjs +35 -21
- package/es/vite/vite-config/vite-dev-config.mjs +1 -2
- package/es/vite/vite-config/vite-pkg-dev-config.mjs +14 -15
- package/es/vite/vite-config/vite-plugin-config.d.ts +22 -6
- package/es/vite/vite-config/vite-plugin-config.mjs +74 -71
- package/es/vite/vite-config/vite-project-config.d.ts +1 -2
- package/es/vite/vite-config/vite-project-config.mjs +9 -62
- package/es/vite/vite-plugins/imnport-external-plugin.d.ts +16 -0
- package/es/vite/vite-plugins/imnport-external-plugin.mjs +14 -0
- package/es/vite/vite-plugins/inject-importmap-plugin.d.ts +19 -0
- package/es/vite/vite-plugins/inject-importmap-plugin.mjs +86 -0
- package/package.json +28 -37
- package/dist/rollup/index.cjs +0 -35
- package/dist/rollup/index.d.ts +0 -3
- package/dist/rollup/rollup-config/build-config.cjs +0 -60
- package/dist/rollup/rollup-config/build-config.d.ts +0 -9
- package/dist/rollup/rollup-config/dev-config.cjs +0 -107
- package/dist/rollup/rollup-config/dev-config.d.ts +0 -9
- package/dist/rollup/rollup-plugins/copy-file.cjs +0 -24
- package/dist/rollup/rollup-plugins/copy-file.d.ts +0 -37
- package/dist/rollup/rollup-plugins/ignore-compiler-file.cjs +0 -23
- package/dist/rollup/rollup-plugins/ignore-compiler-file.d.ts +0 -8
- package/dist/rollup/rollup-plugins/index.cjs +0 -19
- package/dist/rollup/rollup-plugins/index.d.ts +0 -2
- package/dist/vite/gct-opts.interface.cjs +0 -1
- package/dist/vite/gct-opts.interface.d.ts +0 -18
- package/es/rollup/index.d.ts +0 -3
- package/es/rollup/index.mjs +0 -3
- package/es/rollup/rollup-config/build-config.d.ts +0 -9
- package/es/rollup/rollup-config/build-config.mjs +0 -67
- package/es/rollup/rollup-config/dev-config.d.ts +0 -9
- package/es/rollup/rollup-config/dev-config.mjs +0 -124
- package/es/rollup/rollup-plugins/copy-file.d.ts +0 -37
- package/es/rollup/rollup-plugins/copy-file.mjs +0 -18
- package/es/rollup/rollup-plugins/ignore-compiler-file.d.ts +0 -8
- package/es/rollup/rollup-plugins/ignore-compiler-file.mjs +0 -17
- package/es/rollup/rollup-plugins/index.d.ts +0 -2
- package/es/rollup/rollup-plugins/index.mjs +0 -2
- package/es/vite/gct-opts.interface.d.ts +0 -18
- package/es/vite/gct-opts.interface.mjs +0 -0
package/dist/constants/index.cjs
CHANGED
|
@@ -3,8 +3,19 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.PROD_MODE = exports.DEV_MODE = exports.
|
|
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 = ["
|
|
10
|
-
|
|
9
|
+
const DEFAULT_EXTERNAL = exports.DEFAULT_EXTERNAL = ["@babel/standalone", "esprima-next", "estraverse", "escodegen",
|
|
10
|
+
// vue 相关依赖
|
|
11
|
+
"vue", "vue-router", "vue-i18n", "pinia",
|
|
12
|
+
// 第三方依赖
|
|
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
|
+
// 组件库相关依赖
|
|
15
|
+
"vuedraggable", "vue-grid-layout", "vant", "ant-design-vue", "vxe-table",
|
|
16
|
+
// 图标库相关依赖
|
|
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",
|
|
20
|
+
// @gct-paas 独立组件库
|
|
21
|
+
"@gct-paas/platform-icons", "@gct-paas/vue-pdf", "@gct-paas/vue-video-player", "@gct-paas/flow"];
|
|
@@ -52,6 +52,7 @@ function defineEslintConfig(...configs) {
|
|
|
52
52
|
}],
|
|
53
53
|
"no-underscore-dangle": "off",
|
|
54
54
|
"no-restricted-syntax": "off",
|
|
55
|
+
"no-useless-assignment": "off",
|
|
55
56
|
"no-continue": "off",
|
|
56
57
|
"no-unused-vars": "off",
|
|
57
58
|
// 关闭基础规则,由 TypeScript 规则接管
|
|
@@ -79,7 +80,19 @@ function defineEslintConfig(...configs) {
|
|
|
79
80
|
"@typescript-eslint/no-dynamic-delete": "off",
|
|
80
81
|
// 其他规则覆盖
|
|
81
82
|
"class-methods-use-this": "off",
|
|
82
|
-
"prefer-destructuring": "off"
|
|
83
|
+
"prefer-destructuring": "off",
|
|
84
|
+
"no-restricted-imports": ["error", {
|
|
85
|
+
paths: [{
|
|
86
|
+
name: "@/index",
|
|
87
|
+
message: "\u7981\u6B62\u4ECE index \u5BFC\u5165\u5185\u5BB9"
|
|
88
|
+
}, {
|
|
89
|
+
name: "@/loader",
|
|
90
|
+
message: "\u7981\u6B62\u4ECE loader \u5BFC\u5165\u5185\u5BB9"
|
|
91
|
+
}, {
|
|
92
|
+
name: "..",
|
|
93
|
+
message: "\u7981\u6B62\u4ECE\u5185\u90E8\u5BFC\u5165\u5185\u5BB9\u81EA\u8EAB\u5185\u5BB9"
|
|
94
|
+
}]
|
|
95
|
+
}]
|
|
83
96
|
}
|
|
84
97
|
}, {
|
|
85
98
|
name: "ts-vue-override",
|
package/dist/index.cjs
CHANGED
|
@@ -14,6 +14,17 @@ Object.keys(_commitlint).forEach(function (key) {
|
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
16
|
});
|
|
17
|
+
var _constants = require("./constants/index.cjs");
|
|
18
|
+
Object.keys(_constants).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _constants[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _constants[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
17
28
|
var _eslint = require("./eslint/index.cjs");
|
|
18
29
|
Object.keys(_eslint).forEach(function (key) {
|
|
19
30
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -36,17 +47,6 @@ Object.keys(_prettier).forEach(function (key) {
|
|
|
36
47
|
}
|
|
37
48
|
});
|
|
38
49
|
});
|
|
39
|
-
var _rollup = require("./rollup/index.cjs");
|
|
40
|
-
Object.keys(_rollup).forEach(function (key) {
|
|
41
|
-
if (key === "default" || key === "__esModule") return;
|
|
42
|
-
if (key in exports && exports[key] === _rollup[key]) return;
|
|
43
|
-
Object.defineProperty(exports, key, {
|
|
44
|
-
enumerable: true,
|
|
45
|
-
get: function () {
|
|
46
|
-
return _rollup[key];
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
50
|
var _stylelint = require("./stylelint/index.cjs");
|
|
51
51
|
Object.keys(_stylelint).forEach(function (key) {
|
|
52
52
|
if (key === "default" || key === "__esModule") return;
|
package/dist/index.d.ts
CHANGED
|
@@ -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-
|
|
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,
|
package/dist/util/index.cjs
CHANGED
|
@@ -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) {
|
package/dist/util/index.d.ts
CHANGED
package/dist/vite/index.cjs
CHANGED
|
@@ -15,18 +15,36 @@ Object.defineProperty(exports, "defineDevViteConfig", {
|
|
|
15
15
|
return _viteDevConfig.defineDevViteConfig;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
+
Object.defineProperty(exports, "defineLoaderViteConfig", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _viteConfig.defineLoaderViteConfig;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
18
24
|
Object.defineProperty(exports, "defineMobilePluginViteConfig", {
|
|
19
25
|
enumerable: true,
|
|
20
26
|
get: function () {
|
|
21
27
|
return _vitePluginConfig.defineMobilePluginViteConfig;
|
|
22
28
|
}
|
|
23
29
|
});
|
|
30
|
+
Object.defineProperty(exports, "definePadPluginViteConfig", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _vitePluginConfig.definePadPluginViteConfig;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
24
36
|
Object.defineProperty(exports, "definePkgDevViteConfig", {
|
|
25
37
|
enumerable: true,
|
|
26
38
|
get: function () {
|
|
27
39
|
return _vitePkgDevConfig.definePkgDevViteConfig;
|
|
28
40
|
}
|
|
29
41
|
});
|
|
42
|
+
Object.defineProperty(exports, "definePluginViteConfig", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: function () {
|
|
45
|
+
return _vitePluginConfig.definePluginViteConfig;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
30
48
|
Object.defineProperty(exports, "defineProjectViteConfig", {
|
|
31
49
|
enumerable: true,
|
|
32
50
|
get: function () {
|
package/dist/vite/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { defineViteBaseConfig } from './vite-config/vite-base-config';
|
|
2
|
-
export { defineViteConfig } from './vite-config/vite-config';
|
|
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,8 +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
|
-
var _viteTsconfigPaths = _interopRequireDefault(require("vite-tsconfig-paths"));
|
|
12
10
|
var _path = _interopRequireDefault(require("path"));
|
|
13
11
|
var _constants = require("../../constants/index.cjs");
|
|
14
12
|
var _util = require("../../util/index.cjs");
|
|
@@ -17,6 +15,11 @@ function defineViteBaseConfig(opts = {}) {
|
|
|
17
15
|
const cwd = process.cwd();
|
|
18
16
|
const outDir = _path.default.resolve(cwd, "dist");
|
|
19
17
|
return (0, _util.mergeConfig)((0, _vite.defineConfig)({
|
|
18
|
+
resolve: {
|
|
19
|
+
alias: {
|
|
20
|
+
"@": _path.default.resolve(cwd, "./src")
|
|
21
|
+
}
|
|
22
|
+
},
|
|
20
23
|
css: {
|
|
21
24
|
preprocessorOptions: {
|
|
22
25
|
scss: {
|
|
@@ -26,33 +29,11 @@ function defineViteBaseConfig(opts = {}) {
|
|
|
26
29
|
},
|
|
27
30
|
build: {
|
|
28
31
|
outDir,
|
|
29
|
-
|
|
32
|
+
target: "chrome89",
|
|
33
|
+
rolldownOptions: {
|
|
30
34
|
external: _constants.DEFAULT_EXTERNAL
|
|
31
35
|
}
|
|
32
36
|
},
|
|
33
|
-
plugins: [(0,
|
|
34
|
-
hmrTopLevelAwait: false
|
|
35
|
-
})
|
|
36
|
-
// 关系 babel 配置,这个配置要放在具体的 project vite 编译配置中,底包应该是干净的
|
|
37
|
-
// babel({
|
|
38
|
-
// babelHelpers: 'bundled',
|
|
39
|
-
// presets: [
|
|
40
|
-
// [
|
|
41
|
-
// '@babel/preset-env',
|
|
42
|
-
// {
|
|
43
|
-
// useBuiltIns: false,
|
|
44
|
-
// corejs: 3,
|
|
45
|
-
// bugfixes: true,
|
|
46
|
-
// targets: {
|
|
47
|
-
// chrome: '85',
|
|
48
|
-
// edge: '85',
|
|
49
|
-
// firefox: '79',
|
|
50
|
-
// safari: '14.1',
|
|
51
|
-
// },
|
|
52
|
-
// },
|
|
53
|
-
// ],
|
|
54
|
-
// ],
|
|
55
|
-
// }),
|
|
56
|
-
]
|
|
37
|
+
plugins: [(0, _pluginVue.default)(), (0, _pluginVueJsx.default)()]
|
|
57
38
|
}), opts);
|
|
58
39
|
}
|
|
@@ -3,42 +3,52 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.defineLoaderViteConfig = defineLoaderViteConfig;
|
|
6
7
|
exports.defineViteConfig = defineViteConfig;
|
|
7
8
|
var _vite = require("vite");
|
|
8
9
|
var _path = _interopRequireDefault(require("path"));
|
|
9
|
-
var
|
|
10
|
+
var _vite2 = _interopRequireDefault(require("unocss/vite"));
|
|
10
11
|
var _viteBaseConfig = require("./vite-base-config.cjs");
|
|
11
|
-
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); }
|
|
12
|
-
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; }
|
|
13
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
13
|
function defineViteConfig(opts = {}) {
|
|
15
14
|
const cwd = process.cwd();
|
|
16
|
-
const outDir = _path.default.resolve(cwd, "dist");
|
|
17
|
-
rf.sync(outDir);
|
|
18
15
|
return (0, _vite.mergeConfig)((0, _viteBaseConfig.defineViteBaseConfig)((0, _vite.defineConfig)({
|
|
19
16
|
build: {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
minify: "terser",
|
|
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
|
|
24
32
|
},
|
|
25
33
|
lib: {
|
|
26
34
|
entry: _path.default.resolve(cwd, "src/index.ts"),
|
|
27
|
-
formats: ["
|
|
35
|
+
formats: ["es"],
|
|
28
36
|
cssFileName: "index.min",
|
|
29
|
-
fileName
|
|
30
|
-
if (format === "system" || format === "systemjs") {
|
|
31
|
-
return `[name].system.min.js`;
|
|
32
|
-
}
|
|
33
|
-
if (format === "cjs" || format === "commonjs") {
|
|
34
|
-
return `[name].min.cjs`;
|
|
35
|
-
}
|
|
36
|
-
if (format === "es" || format === "esm" || format === "module") {
|
|
37
|
-
return `[name].esm.min.mjs`;
|
|
38
|
-
}
|
|
39
|
-
return `[name].${format}.min.js`;
|
|
40
|
-
}
|
|
37
|
+
fileName: "[name].[format].min"
|
|
41
38
|
}
|
|
42
|
-
}
|
|
39
|
+
},
|
|
40
|
+
plugins: [(0, _vite2.default)({
|
|
41
|
+
hmrTopLevelAwait: false
|
|
42
|
+
})]
|
|
43
43
|
})), opts);
|
|
44
|
+
}
|
|
45
|
+
function defineLoaderViteConfig(opts = {}) {
|
|
46
|
+
const cwd = process.cwd();
|
|
47
|
+
return (0, _vite.mergeConfig)(defineViteConfig({
|
|
48
|
+
build: {
|
|
49
|
+
lib: {
|
|
50
|
+
entry: _path.default.resolve(cwd, "src/loader.ts")
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}), opts);
|
|
44
54
|
}
|
|
@@ -7,3 +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
|
+
*/
|
|
17
|
+
export declare function defineLoaderViteConfig(opts?: UserConfig): UserConfig;
|
|
@@ -7,7 +7,6 @@ exports.defineDevViteConfig = defineDevViteConfig;
|
|
|
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 _pluginJson = _interopRequireDefault(require("@rollup/plugin-json"));
|
|
11
10
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
11
|
function defineDevViteConfig(opts = {}) {
|
|
13
12
|
return (0, _vite.mergeConfig)((0, _vite.defineConfig)({
|
|
@@ -18,6 +17,6 @@ function defineDevViteConfig(opts = {}) {
|
|
|
18
17
|
}
|
|
19
18
|
}
|
|
20
19
|
},
|
|
21
|
-
plugins: [(0,
|
|
20
|
+
plugins: [(0, _pluginVue.default)(), (0, _pluginVueJsx.default)()]
|
|
22
21
|
}), opts);
|
|
23
22
|
}
|
|
@@ -10,11 +10,9 @@ var rf = _interopRequireWildcard(require("rimraf"));
|
|
|
10
10
|
var _pluginVue = _interopRequireDefault(require("@vitejs/plugin-vue"));
|
|
11
11
|
var _pluginVueJsx = _interopRequireDefault(require("@vitejs/plugin-vue-jsx"));
|
|
12
12
|
var _vitePluginLibInjectCss = require("vite-plugin-lib-inject-css");
|
|
13
|
-
var _viteTsconfigPaths = _interopRequireDefault(require("vite-tsconfig-paths"));
|
|
14
13
|
var _vitePluginStaticCopy = require("vite-plugin-static-copy");
|
|
15
14
|
var _vitePluginDts = _interopRequireDefault(require("vite-plugin-dts"));
|
|
16
15
|
var _fs = require("fs");
|
|
17
|
-
var _vite2 = _interopRequireDefault(require("unocss/vite"));
|
|
18
16
|
var _util = require("../../util/index.cjs");
|
|
19
17
|
var _constants = require("../../constants/index.cjs");
|
|
20
18
|
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); }
|
|
@@ -46,7 +44,7 @@ function definePkgDevViteConfig(opts = {}) {
|
|
|
46
44
|
target: "esnext",
|
|
47
45
|
minify: false,
|
|
48
46
|
sourcemap: isDev,
|
|
49
|
-
|
|
47
|
+
rolldownOptions: {
|
|
50
48
|
external: id => {
|
|
51
49
|
if (pkgDependencies.some(dep => id === dep || id.startsWith(dep + "/"))) {
|
|
52
50
|
return true;
|
|
@@ -73,21 +71,21 @@ function definePkgDevViteConfig(opts = {}) {
|
|
|
73
71
|
formats: ["es"]
|
|
74
72
|
}
|
|
75
73
|
},
|
|
76
|
-
plugins: [(0,
|
|
77
|
-
|
|
78
|
-
|
|
74
|
+
plugins: [(0, _pluginVue.default)(), (0, _pluginVueJsx.default)(),
|
|
75
|
+
// UnoCSS({ hmrTopLevelAwait: false }) as PluginOption,
|
|
76
|
+
(0, _vitePluginLibInjectCss.libInjectCss)(), (0, _vitePluginDts.default)({
|
|
79
77
|
outDir: [outDir],
|
|
80
78
|
compilerOptions: {
|
|
81
79
|
declarationMap: isDev
|
|
82
80
|
},
|
|
83
81
|
// 排除测试目录,以及测试文件
|
|
84
82
|
exclude: ["**/test/**", "**/*.test.ts", "**/*.test.tsx", "**/*.spec.ts", "**/*.spec.tsx"]
|
|
85
|
-
}), (0, _vitePluginStaticCopy.viteStaticCopy)({
|
|
83
|
+
}), ...((0, _fs.existsSync)(_path.default.resolve(cwd, "src/types")) ? [(0, _vitePluginStaticCopy.viteStaticCopy)({
|
|
86
84
|
targets: [{
|
|
87
85
|
// 将 src/types 目录下的文件复制到编译输出目录
|
|
88
86
|
src: "src/types",
|
|
89
87
|
dest: "."
|
|
90
88
|
}]
|
|
91
|
-
})]
|
|
89
|
+
})] : [])]
|
|
92
90
|
}), opts);
|
|
93
91
|
}
|
|
@@ -5,96 +5,94 @@ 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
|
-
|
|
14
|
-
function formatFileName(format) {
|
|
15
|
-
if (format === "system" || format === "systemjs") {
|
|
16
|
-
return `[name].system.min.js`;
|
|
17
|
-
}
|
|
18
|
-
if (format === "cjs" || format === "commonjs") {
|
|
19
|
-
return `[name].min.cjs`;
|
|
20
|
-
}
|
|
21
|
-
if (format === "es" || format === "esm" || format === "module") {
|
|
22
|
-
return `[name].esm.min.mjs`;
|
|
23
|
-
}
|
|
24
|
-
return `[name].${format}.min.js`;
|
|
25
|
-
}
|
|
26
|
-
function assetFileNames(assetInfo, name) {
|
|
27
|
-
if (assetInfo.names.length > 0 && assetInfo.names[0].endsWith(".css")) {
|
|
28
|
-
return name + ".min.css";
|
|
29
|
-
}
|
|
30
|
-
return assetInfo.names[0];
|
|
31
|
-
}
|
|
32
|
-
function defineDesignPluginViteConfig(opts = {}) {
|
|
17
|
+
function definePluginViteConfig(opts = {}) {
|
|
33
18
|
const cwd = process.cwd();
|
|
34
|
-
const
|
|
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";
|
|
35
22
|
return (0, _vite.mergeConfig)((0, _viteBaseConfig.defineViteBaseConfig)({
|
|
23
|
+
optimizeDeps: {
|
|
24
|
+
exclude: _constants.DEFAULT_EXTERNAL
|
|
25
|
+
},
|
|
36
26
|
build: {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
|
44
42
|
},
|
|
45
43
|
lib: {
|
|
46
|
-
entry:
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
fileName: formatFileName
|
|
44
|
+
entry: isProd ? loaderEntry : entry,
|
|
45
|
+
formats: ["es"],
|
|
46
|
+
cssFileName: "index.min",
|
|
47
|
+
fileName: "[name].[format].min"
|
|
51
48
|
}
|
|
49
|
+
},
|
|
50
|
+
plugins: [...(0, _imnportExternalPlugin.importMapExternalPlugin)(_constants.DEFAULT_EXTERNAL)
|
|
51
|
+
// federation({
|
|
52
|
+
// name: 'gct-paas-plugin',
|
|
53
|
+
// filename: 'remoteEntry.js',
|
|
54
|
+
// dts: false,
|
|
55
|
+
// manifest: true,
|
|
56
|
+
// exposes: {
|
|
57
|
+
// '.': './src/index.ts',
|
|
58
|
+
// },
|
|
59
|
+
// }),
|
|
60
|
+
]
|
|
61
|
+
}), opts);
|
|
62
|
+
}
|
|
63
|
+
function defineDesignPluginViteConfig(opts = {}) {
|
|
64
|
+
return (0, _vite.mergeConfig)(definePluginViteConfig({
|
|
65
|
+
server: {
|
|
66
|
+
port: 7001,
|
|
67
|
+
host: "0.0.0.0",
|
|
68
|
+
allowedHosts: true
|
|
52
69
|
}
|
|
53
70
|
}), opts);
|
|
54
71
|
}
|
|
55
72
|
function defineMobilePluginViteConfig(opts = {}) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
mobile: mobileEntry
|
|
71
|
-
},
|
|
72
|
-
formats,
|
|
73
|
-
fileName: formatFileName
|
|
74
|
-
}
|
|
73
|
+
return (0, _vite.mergeConfig)(definePluginViteConfig({
|
|
74
|
+
server: {
|
|
75
|
+
port: 7002,
|
|
76
|
+
host: "0.0.0.0",
|
|
77
|
+
allowedHosts: true
|
|
78
|
+
}
|
|
79
|
+
}), opts);
|
|
80
|
+
}
|
|
81
|
+
function definePadPluginViteConfig(opts = {}) {
|
|
82
|
+
return (0, _vite.mergeConfig)(definePluginViteConfig({
|
|
83
|
+
server: {
|
|
84
|
+
port: 7003,
|
|
85
|
+
host: "0.0.0.0",
|
|
86
|
+
allowedHosts: true
|
|
75
87
|
}
|
|
76
88
|
}), opts);
|
|
77
89
|
}
|
|
78
90
|
function defineWebPluginViteConfig(opts = {}) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
rollupOptions: {
|
|
85
|
-
output: {
|
|
86
|
-
assetFileNames: assetInfo => {
|
|
87
|
-
return assetFileNames(assetInfo, "web");
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
},
|
|
91
|
-
lib: {
|
|
92
|
-
entry: {
|
|
93
|
-
web: webEntry
|
|
94
|
-
},
|
|
95
|
-
formats,
|
|
96
|
-
fileName: formatFileName
|
|
97
|
-
}
|
|
91
|
+
return (0, _vite.mergeConfig)(definePluginViteConfig({
|
|
92
|
+
server: {
|
|
93
|
+
port: 7004,
|
|
94
|
+
host: "0.0.0.0",
|
|
95
|
+
allowedHosts: true
|
|
98
96
|
}
|
|
99
97
|
}), opts);
|
|
100
98
|
}
|
|
@@ -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
|
-
* @
|
|
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
|
-
* @
|
|
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
|
-
* @
|
|
39
|
+
* @return {*} {UserConfig}
|
|
24
40
|
*/
|
|
25
41
|
export declare function defineWebPluginViteConfig(opts?: UserConfig): UserConfig;
|