@gct-paas/build 0.1.5-dev.9 → 0.1.6-dev.1
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 +1 -1
- package/dist/eslint/eslint-config/eslint-config.cjs +1 -0
- package/dist/index.cjs +0 -11
- package/dist/index.d.ts +0 -1
- package/dist/vite/vite-config/vite-base-config.cjs +2 -24
- package/dist/vite/vite-config/vite-config.cjs +2 -18
- package/dist/vite/vite-config/vite-dev-config.cjs +1 -2
- package/dist/vite/vite-config/vite-pkg-dev-config.cjs +4 -6
- package/dist/vite/vite-config/vite-project-config.cjs +3 -41
- package/dist/vite/vite-config/vite-project-config.d.ts +1 -2
- package/es/constants/index.mjs +13 -3
- package/es/eslint/eslint-config/eslint-config.mjs +1 -0
- package/es/index.d.ts +0 -1
- package/es/index.mjs +0 -1
- package/es/vite/vite-config/vite-base-config.mjs +0 -22
- package/es/vite/vite-config/vite-config.mjs +2 -18
- package/es/vite/vite-config/vite-dev-config.mjs +1 -2
- package/es/vite/vite-config/vite-pkg-dev-config.mjs +2 -5
- package/es/vite/vite-config/vite-project-config.d.ts +1 -2
- package/es/vite/vite-config/vite-project-config.mjs +18 -46
- package/package.json +19 -34
- 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/rollup/index.cjs
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var _exportNames = {
|
|
7
|
-
defineRollupBuildConfig: true,
|
|
8
|
-
defineRollupConfig: true
|
|
9
|
-
};
|
|
10
|
-
Object.defineProperty(exports, "defineRollupBuildConfig", {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () {
|
|
13
|
-
return _buildConfig.defineRollupBuildConfig;
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
Object.defineProperty(exports, "defineRollupConfig", {
|
|
17
|
-
enumerable: true,
|
|
18
|
-
get: function () {
|
|
19
|
-
return _devConfig.defineRollupConfig;
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
var _buildConfig = require("./rollup-config/build-config.cjs");
|
|
23
|
-
var _devConfig = require("./rollup-config/dev-config.cjs");
|
|
24
|
-
var _rollupPlugins = require("./rollup-plugins/index.cjs");
|
|
25
|
-
Object.keys(_rollupPlugins).forEach(function (key) {
|
|
26
|
-
if (key === "default" || key === "__esModule") return;
|
|
27
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
28
|
-
if (key in exports && exports[key] === _rollupPlugins[key]) return;
|
|
29
|
-
Object.defineProperty(exports, key, {
|
|
30
|
-
enumerable: true,
|
|
31
|
-
get: function () {
|
|
32
|
-
return _rollupPlugins[key];
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
});
|
package/dist/rollup/index.d.ts
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.defineRollupBuildConfig = defineRollupBuildConfig;
|
|
7
|
-
var _rollup = require("rollup");
|
|
8
|
-
var _path = _interopRequireDefault(require("path"));
|
|
9
|
-
var _pluginNodeResolve = require("@rollup/plugin-node-resolve");
|
|
10
|
-
var _pluginCommonjs = _interopRequireDefault(require("@rollup/plugin-commonjs"));
|
|
11
|
-
var _pluginJson = _interopRequireDefault(require("@rollup/plugin-json"));
|
|
12
|
-
var _rollupPluginEsbuild = _interopRequireWildcard(require("rollup-plugin-esbuild"));
|
|
13
|
-
var _pluginVue = _interopRequireDefault(require("@vitejs/plugin-vue"));
|
|
14
|
-
var _pluginVueJsx = _interopRequireDefault(require("@vitejs/plugin-vue-jsx"));
|
|
15
|
-
var rf = _interopRequireWildcard(require("rimraf"));
|
|
16
|
-
var _rollupPlugins = require("../rollup-plugins/index.cjs");
|
|
17
|
-
var _constants = require("../../constants/index.cjs");
|
|
18
|
-
var _util = require("../../util/index.cjs");
|
|
19
|
-
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); }
|
|
20
|
-
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; }
|
|
21
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
22
|
-
function defineRollupBuildConfig(opts = {}) {
|
|
23
|
-
process.on("SIGINT", () => {
|
|
24
|
-
process.exit();
|
|
25
|
-
});
|
|
26
|
-
const cwd = process.cwd();
|
|
27
|
-
const isProd = process.env.NODE_ENV === _constants.PROD_MODE;
|
|
28
|
-
const outDir = _path.default.resolve(cwd, "es");
|
|
29
|
-
const externalCompileFileReg = /\.(d\.ts)+$/;
|
|
30
|
-
rf.sync(outDir);
|
|
31
|
-
const output = [{
|
|
32
|
-
file: "dist/index.esm.min.js",
|
|
33
|
-
format: "es"
|
|
34
|
-
}, {
|
|
35
|
-
file: "dist/index.system.min.js",
|
|
36
|
-
format: "system"
|
|
37
|
-
}, {
|
|
38
|
-
file: "dist/index.cjs.min.js",
|
|
39
|
-
format: "cjs",
|
|
40
|
-
exports: "named"
|
|
41
|
-
}];
|
|
42
|
-
return (0, _util.mergeConfig)((0, _rollup.defineConfig)({
|
|
43
|
-
input: "src/index.ts",
|
|
44
|
-
treeshake: false,
|
|
45
|
-
external: _constants.DEFAULT_EXTERNAL,
|
|
46
|
-
output,
|
|
47
|
-
plugins: [(0, _rollupPlugins.ignoreCompilerFile)(externalCompileFileReg), (0, _pluginJson.default)(), (0, _pluginVue.default)({
|
|
48
|
-
isProduction: isProd
|
|
49
|
-
}), (0, _pluginVueJsx.default)({}), (0, _pluginNodeResolve.nodeResolve)({
|
|
50
|
-
extensions: [".cjs", ".mjs", ".js", ".ts"]
|
|
51
|
-
}), (0, _pluginCommonjs.default)(), (0, _rollupPluginEsbuild.default)({
|
|
52
|
-
logLevel: "verbose",
|
|
53
|
-
sourceMap: false,
|
|
54
|
-
target: ["esnext"],
|
|
55
|
-
loaders: {
|
|
56
|
-
".vue": "ts"
|
|
57
|
-
}
|
|
58
|
-
}), (0, _rollupPluginEsbuild.minify)()]
|
|
59
|
-
}), opts);
|
|
60
|
-
}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.defineRollupConfig = defineRollupConfig;
|
|
7
|
-
var _rollup = require("rollup");
|
|
8
|
-
var _path = _interopRequireDefault(require("path"));
|
|
9
|
-
var _pluginNodeResolve = require("@rollup/plugin-node-resolve");
|
|
10
|
-
var _pluginCommonjs = _interopRequireDefault(require("@rollup/plugin-commonjs"));
|
|
11
|
-
var _pluginJson = _interopRequireDefault(require("@rollup/plugin-json"));
|
|
12
|
-
var _rollupPluginEsbuild = _interopRequireDefault(require("rollup-plugin-esbuild"));
|
|
13
|
-
var _vitePluginDts = _interopRequireDefault(require("vite-plugin-dts"));
|
|
14
|
-
var _pluginVue = _interopRequireDefault(require("@vitejs/plugin-vue"));
|
|
15
|
-
var _pluginVueJsx = _interopRequireDefault(require("@vitejs/plugin-vue-jsx"));
|
|
16
|
-
var rf = _interopRequireWildcard(require("rimraf"));
|
|
17
|
-
var _cpy = _interopRequireDefault(require("cpy"));
|
|
18
|
-
var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
19
|
-
var _os = _interopRequireDefault(require("os"));
|
|
20
|
-
var _rollupPlugins = require("../rollup-plugins/index.cjs");
|
|
21
|
-
var _constants = require("../../constants/index.cjs");
|
|
22
|
-
var _util = require("../../util/index.cjs");
|
|
23
|
-
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); }
|
|
24
|
-
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; }
|
|
25
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
26
|
-
function defineRollupConfig(opts = {}) {
|
|
27
|
-
process.on("SIGINT", () => {
|
|
28
|
-
process.exit();
|
|
29
|
-
});
|
|
30
|
-
const cwd = process.cwd();
|
|
31
|
-
const isProd = process.env.NODE_ENV === _constants.PROD_MODE;
|
|
32
|
-
const rootDir = _path.default.resolve(cwd, "src");
|
|
33
|
-
const outDir = _path.default.resolve(cwd, "es");
|
|
34
|
-
const assetsDir = _path.default.resolve(cwd, "public");
|
|
35
|
-
const externalCompileFileReg = /\.(scss|css|less|d\.ts)+$/;
|
|
36
|
-
rf.sync(outDir);
|
|
37
|
-
if (isProd) {
|
|
38
|
-
const isWin = _os.default.platform() === "win32";
|
|
39
|
-
if (isWin) {
|
|
40
|
-
if (_fsExtra.default.pathExistsSync(assetsDir)) {
|
|
41
|
-
(0, _cpy.default)((0, _util.winToUnixPath)(assetsDir), (0, _util.winToUnixPath)(outDir));
|
|
42
|
-
}
|
|
43
|
-
(0, _cpy.default)((0, _util.winToUnixPath)(_path.default.resolve(cwd, "src/**/*.{scss,css,less,d.ts}")), (0, _util.winToUnixPath)(outDir));
|
|
44
|
-
} else {
|
|
45
|
-
if (_fsExtra.default.pathExistsSync(assetsDir)) {
|
|
46
|
-
(0, _cpy.default)(assetsDir, outDir);
|
|
47
|
-
}
|
|
48
|
-
(0, _cpy.default)(_path.default.resolve(cwd, "src/**/*.{scss,css,less,d.ts}"), outDir);
|
|
49
|
-
}
|
|
50
|
-
} else {
|
|
51
|
-
(0, _rollupPlugins.copyFile)([{
|
|
52
|
-
from: assetsDir,
|
|
53
|
-
to: outDir
|
|
54
|
-
}, {
|
|
55
|
-
from: rootDir,
|
|
56
|
-
to: outDir,
|
|
57
|
-
opts: {
|
|
58
|
-
ignored: (file, stats) => {
|
|
59
|
-
if (stats && stats.isFile()) {
|
|
60
|
-
return !externalCompileFileReg.test(file);
|
|
61
|
-
}
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}]);
|
|
66
|
-
}
|
|
67
|
-
const output = [{
|
|
68
|
-
dir: outDir,
|
|
69
|
-
esModule: true,
|
|
70
|
-
format: "es",
|
|
71
|
-
sourcemap: false,
|
|
72
|
-
preserveModules: true,
|
|
73
|
-
preserveModulesRoot: rootDir,
|
|
74
|
-
exports: "named",
|
|
75
|
-
entryFileNames: "[name].mjs"
|
|
76
|
-
}];
|
|
77
|
-
return (0, _util.mergeConfig)((0, _rollup.defineConfig)({
|
|
78
|
-
input: "src/index.ts",
|
|
79
|
-
treeshake: false,
|
|
80
|
-
external: id => {
|
|
81
|
-
if (_util.IS_NODE_MODULE.test(id)) {
|
|
82
|
-
return true;
|
|
83
|
-
}
|
|
84
|
-
if (_constants.DEFAULT_EXTERNAL.includes(id)) {
|
|
85
|
-
return true;
|
|
86
|
-
}
|
|
87
|
-
return false;
|
|
88
|
-
},
|
|
89
|
-
output,
|
|
90
|
-
plugins: [(0, _rollupPlugins.ignoreCompilerFile)(externalCompileFileReg), (0, _pluginJson.default)(), (0, _pluginVue.default)({
|
|
91
|
-
isProduction: isProd
|
|
92
|
-
}), (0, _pluginVueJsx.default)({}), (0, _pluginNodeResolve.nodeResolve)({
|
|
93
|
-
extensions: [".cjs", ".mjs", ".js", ".ts"]
|
|
94
|
-
}), (0, _pluginCommonjs.default)(), (0, _rollupPluginEsbuild.default)({
|
|
95
|
-
logLevel: "verbose",
|
|
96
|
-
sourceMap: false,
|
|
97
|
-
target: ["esnext"],
|
|
98
|
-
loaders: {
|
|
99
|
-
".vue": "ts"
|
|
100
|
-
}
|
|
101
|
-
}), (0, _vitePluginDts.default)({
|
|
102
|
-
outDir: [outDir],
|
|
103
|
-
// 排除测试目录,以及测试文件
|
|
104
|
-
exclude: ["**/test/**", "**/*.test.ts", "**/*.test.tsx", "**/*.spec.ts", "**/*.spec.tsx"]
|
|
105
|
-
})]
|
|
106
|
-
}), opts);
|
|
107
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.copyFile = copyFile;
|
|
7
|
-
var _util = require("../../util/index.cjs");
|
|
8
|
-
function copyFile(opts) {
|
|
9
|
-
if (opts.length === 0) {
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
const arr = [];
|
|
13
|
-
opts.forEach(opt => {
|
|
14
|
-
arr.push(new _util.CopyWatch(opt.from, opt.to, opt.opts));
|
|
15
|
-
});
|
|
16
|
-
process.on("exit", () => {
|
|
17
|
-
if (!opts.length) {
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
arr.forEach(item => {
|
|
21
|
-
item.unwatch();
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import * as chokidar from 'chokidar';
|
|
2
|
-
/**
|
|
3
|
-
* 文件拷贝插件配置参数
|
|
4
|
-
*
|
|
5
|
-
* @export
|
|
6
|
-
* @interface CopyFilePluginOptions
|
|
7
|
-
*/
|
|
8
|
-
export interface CopyFilePluginOptions {
|
|
9
|
-
/**
|
|
10
|
-
* 源文件
|
|
11
|
-
*
|
|
12
|
-
* @type {string}
|
|
13
|
-
* @memberof CopyFilePluginOptions
|
|
14
|
-
*/
|
|
15
|
-
from: string;
|
|
16
|
-
/**
|
|
17
|
-
* 目标文件
|
|
18
|
-
*
|
|
19
|
-
* @type {string}
|
|
20
|
-
* @memberof CopyFilePluginOptions
|
|
21
|
-
*/
|
|
22
|
-
to: string;
|
|
23
|
-
/**
|
|
24
|
-
* chokidar watch 配置
|
|
25
|
-
*
|
|
26
|
-
* @type {chokidar.ChokidarOptions}
|
|
27
|
-
*/
|
|
28
|
-
opts?: chokidar.ChokidarOptions;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* 文件拷贝插件,在开发模式下会监控文件变更,并自动拷贝文件
|
|
32
|
-
*
|
|
33
|
-
* @export
|
|
34
|
-
* @param {CopyFilePluginOptions[]} opts
|
|
35
|
-
* @return {*} {Plugin}
|
|
36
|
-
*/
|
|
37
|
-
export declare function copyFile(opts: CopyFilePluginOptions[]): void;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.ignoreCompilerFile = ignoreCompilerFile;
|
|
7
|
-
function ignoreCompilerFile(extReg) {
|
|
8
|
-
return {
|
|
9
|
-
name: "gct:ignore-compiler-file",
|
|
10
|
-
resolveId(source) {
|
|
11
|
-
if (extReg.test(source)) {
|
|
12
|
-
return {
|
|
13
|
-
id: source,
|
|
14
|
-
external: true
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
return null;
|
|
18
|
-
},
|
|
19
|
-
load() {
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "copyFile", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _copyFile.copyFile;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "ignoreCompilerFile", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _ignoreCompilerFile.ignoreCompilerFile;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
var _copyFile = require("./copy-file.cjs");
|
|
19
|
-
var _ignoreCompilerFile = require("./ignore-compiler-file.cjs");
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1,18 +0,0 @@
|
|
|
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
|
-
}
|
package/es/rollup/index.d.ts
DELETED
package/es/rollup/index.mjs
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from "rollup";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import { nodeResolve } from "@rollup/plugin-node-resolve";
|
|
4
|
-
import commonjs from "@rollup/plugin-commonjs";
|
|
5
|
-
import json from "@rollup/plugin-json";
|
|
6
|
-
import esbuild, { minify } from "rollup-plugin-esbuild";
|
|
7
|
-
import vue from "@vitejs/plugin-vue";
|
|
8
|
-
import vueJsx from "@vitejs/plugin-vue-jsx";
|
|
9
|
-
import * as rf from "rimraf";
|
|
10
|
-
import { ignoreCompilerFile } from "../rollup-plugins/index.mjs";
|
|
11
|
-
import { DEFAULT_EXTERNAL, PROD_MODE } from "../../constants/index.mjs";
|
|
12
|
-
import { mergeConfig } from "../../util/index.mjs";
|
|
13
|
-
export function defineRollupBuildConfig(opts = {}) {
|
|
14
|
-
process.on("SIGINT", () => {
|
|
15
|
-
process.exit();
|
|
16
|
-
});
|
|
17
|
-
const cwd = process.cwd();
|
|
18
|
-
const isProd = process.env.NODE_ENV === PROD_MODE;
|
|
19
|
-
const outDir = path.resolve(cwd, "es");
|
|
20
|
-
const externalCompileFileReg = /\.(d\.ts)+$/;
|
|
21
|
-
rf.sync(outDir);
|
|
22
|
-
const output = [
|
|
23
|
-
{
|
|
24
|
-
file: "dist/index.esm.min.js",
|
|
25
|
-
format: "es"
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
file: "dist/index.system.min.js",
|
|
29
|
-
format: "system"
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
file: "dist/index.cjs.min.js",
|
|
33
|
-
format: "cjs",
|
|
34
|
-
exports: "named"
|
|
35
|
-
}
|
|
36
|
-
];
|
|
37
|
-
return mergeConfig(
|
|
38
|
-
defineConfig({
|
|
39
|
-
input: "src/index.ts",
|
|
40
|
-
treeshake: false,
|
|
41
|
-
external: DEFAULT_EXTERNAL,
|
|
42
|
-
output,
|
|
43
|
-
plugins: [
|
|
44
|
-
ignoreCompilerFile(externalCompileFileReg),
|
|
45
|
-
json(),
|
|
46
|
-
vue({
|
|
47
|
-
isProduction: isProd
|
|
48
|
-
}),
|
|
49
|
-
vueJsx({}),
|
|
50
|
-
nodeResolve({
|
|
51
|
-
extensions: [".cjs", ".mjs", ".js", ".ts"]
|
|
52
|
-
}),
|
|
53
|
-
commonjs(),
|
|
54
|
-
esbuild({
|
|
55
|
-
logLevel: "verbose",
|
|
56
|
-
sourceMap: false,
|
|
57
|
-
target: ["esnext"],
|
|
58
|
-
loaders: {
|
|
59
|
-
".vue": "ts"
|
|
60
|
-
}
|
|
61
|
-
}),
|
|
62
|
-
minify()
|
|
63
|
-
]
|
|
64
|
-
}),
|
|
65
|
-
opts
|
|
66
|
-
);
|
|
67
|
-
}
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from "rollup";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import { nodeResolve } from "@rollup/plugin-node-resolve";
|
|
4
|
-
import commonjs from "@rollup/plugin-commonjs";
|
|
5
|
-
import json from "@rollup/plugin-json";
|
|
6
|
-
import esbuild from "rollup-plugin-esbuild";
|
|
7
|
-
import dts from "vite-plugin-dts";
|
|
8
|
-
import vue from "@vitejs/plugin-vue";
|
|
9
|
-
import vueJsx from "@vitejs/plugin-vue-jsx";
|
|
10
|
-
import * as rf from "rimraf";
|
|
11
|
-
import cpy from "cpy";
|
|
12
|
-
import fs from "fs-extra";
|
|
13
|
-
import os from "os";
|
|
14
|
-
import { copyFile, ignoreCompilerFile } from "../rollup-plugins/index.mjs";
|
|
15
|
-
import { DEFAULT_EXTERNAL, PROD_MODE } from "../../constants/index.mjs";
|
|
16
|
-
import { IS_NODE_MODULE, mergeConfig, winToUnixPath } from "../../util/index.mjs";
|
|
17
|
-
export function defineRollupConfig(opts = {}) {
|
|
18
|
-
process.on("SIGINT", () => {
|
|
19
|
-
process.exit();
|
|
20
|
-
});
|
|
21
|
-
const cwd = process.cwd();
|
|
22
|
-
const isProd = process.env.NODE_ENV === PROD_MODE;
|
|
23
|
-
const rootDir = path.resolve(cwd, "src");
|
|
24
|
-
const outDir = path.resolve(cwd, "es");
|
|
25
|
-
const assetsDir = path.resolve(cwd, "public");
|
|
26
|
-
const externalCompileFileReg = /\.(scss|css|less|d\.ts)+$/;
|
|
27
|
-
rf.sync(outDir);
|
|
28
|
-
if (isProd) {
|
|
29
|
-
const isWin = os.platform() === "win32";
|
|
30
|
-
if (isWin) {
|
|
31
|
-
if (fs.pathExistsSync(assetsDir)) {
|
|
32
|
-
cpy(winToUnixPath(assetsDir), winToUnixPath(outDir));
|
|
33
|
-
}
|
|
34
|
-
cpy(
|
|
35
|
-
winToUnixPath(path.resolve(cwd, "src/**/*.{scss,css,less,d.ts}")),
|
|
36
|
-
winToUnixPath(outDir)
|
|
37
|
-
);
|
|
38
|
-
} else {
|
|
39
|
-
if (fs.pathExistsSync(assetsDir)) {
|
|
40
|
-
cpy(assetsDir, outDir);
|
|
41
|
-
}
|
|
42
|
-
cpy(path.resolve(cwd, "src/**/*.{scss,css,less,d.ts}"), outDir);
|
|
43
|
-
}
|
|
44
|
-
} else {
|
|
45
|
-
copyFile([
|
|
46
|
-
{
|
|
47
|
-
from: assetsDir,
|
|
48
|
-
to: outDir
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
from: rootDir,
|
|
52
|
-
to: outDir,
|
|
53
|
-
opts: {
|
|
54
|
-
ignored: (file, stats) => {
|
|
55
|
-
if (stats && stats.isFile()) {
|
|
56
|
-
return !externalCompileFileReg.test(file);
|
|
57
|
-
}
|
|
58
|
-
return false;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
]);
|
|
63
|
-
}
|
|
64
|
-
const output = [
|
|
65
|
-
{
|
|
66
|
-
dir: outDir,
|
|
67
|
-
esModule: true,
|
|
68
|
-
format: "es",
|
|
69
|
-
sourcemap: false,
|
|
70
|
-
preserveModules: true,
|
|
71
|
-
preserveModulesRoot: rootDir,
|
|
72
|
-
exports: "named",
|
|
73
|
-
entryFileNames: "[name].mjs"
|
|
74
|
-
}
|
|
75
|
-
];
|
|
76
|
-
return mergeConfig(
|
|
77
|
-
defineConfig({
|
|
78
|
-
input: "src/index.ts",
|
|
79
|
-
treeshake: false,
|
|
80
|
-
external: (id) => {
|
|
81
|
-
if (IS_NODE_MODULE.test(id)) {
|
|
82
|
-
return true;
|
|
83
|
-
}
|
|
84
|
-
if (DEFAULT_EXTERNAL.includes(id)) {
|
|
85
|
-
return true;
|
|
86
|
-
}
|
|
87
|
-
return false;
|
|
88
|
-
},
|
|
89
|
-
output,
|
|
90
|
-
plugins: [
|
|
91
|
-
ignoreCompilerFile(externalCompileFileReg),
|
|
92
|
-
json(),
|
|
93
|
-
vue({
|
|
94
|
-
isProduction: isProd
|
|
95
|
-
}),
|
|
96
|
-
vueJsx({}),
|
|
97
|
-
nodeResolve({
|
|
98
|
-
extensions: [".cjs", ".mjs", ".js", ".ts"]
|
|
99
|
-
}),
|
|
100
|
-
commonjs(),
|
|
101
|
-
esbuild({
|
|
102
|
-
logLevel: "verbose",
|
|
103
|
-
sourceMap: false,
|
|
104
|
-
target: ["esnext"],
|
|
105
|
-
loaders: {
|
|
106
|
-
".vue": "ts"
|
|
107
|
-
}
|
|
108
|
-
}),
|
|
109
|
-
dts({
|
|
110
|
-
outDir: [outDir],
|
|
111
|
-
// 排除测试目录,以及测试文件
|
|
112
|
-
exclude: [
|
|
113
|
-
"**/test/**",
|
|
114
|
-
"**/*.test.ts",
|
|
115
|
-
"**/*.test.tsx",
|
|
116
|
-
"**/*.spec.ts",
|
|
117
|
-
"**/*.spec.tsx"
|
|
118
|
-
]
|
|
119
|
-
})
|
|
120
|
-
]
|
|
121
|
-
}),
|
|
122
|
-
opts
|
|
123
|
-
);
|
|
124
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import * as chokidar from 'chokidar';
|
|
2
|
-
/**
|
|
3
|
-
* 文件拷贝插件配置参数
|
|
4
|
-
*
|
|
5
|
-
* @export
|
|
6
|
-
* @interface CopyFilePluginOptions
|
|
7
|
-
*/
|
|
8
|
-
export interface CopyFilePluginOptions {
|
|
9
|
-
/**
|
|
10
|
-
* 源文件
|
|
11
|
-
*
|
|
12
|
-
* @type {string}
|
|
13
|
-
* @memberof CopyFilePluginOptions
|
|
14
|
-
*/
|
|
15
|
-
from: string;
|
|
16
|
-
/**
|
|
17
|
-
* 目标文件
|
|
18
|
-
*
|
|
19
|
-
* @type {string}
|
|
20
|
-
* @memberof CopyFilePluginOptions
|
|
21
|
-
*/
|
|
22
|
-
to: string;
|
|
23
|
-
/**
|
|
24
|
-
* chokidar watch 配置
|
|
25
|
-
*
|
|
26
|
-
* @type {chokidar.ChokidarOptions}
|
|
27
|
-
*/
|
|
28
|
-
opts?: chokidar.ChokidarOptions;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* 文件拷贝插件,在开发模式下会监控文件变更,并自动拷贝文件
|
|
32
|
-
*
|
|
33
|
-
* @export
|
|
34
|
-
* @param {CopyFilePluginOptions[]} opts
|
|
35
|
-
* @return {*} {Plugin}
|
|
36
|
-
*/
|
|
37
|
-
export declare function copyFile(opts: CopyFilePluginOptions[]): void;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { CopyWatch } from "../../util/index.mjs";
|
|
2
|
-
export function copyFile(opts) {
|
|
3
|
-
if (opts.length === 0) {
|
|
4
|
-
return;
|
|
5
|
-
}
|
|
6
|
-
const arr = [];
|
|
7
|
-
opts.forEach((opt) => {
|
|
8
|
-
arr.push(new CopyWatch(opt.from, opt.to, opt.opts));
|
|
9
|
-
});
|
|
10
|
-
process.on("exit", () => {
|
|
11
|
-
if (!opts.length) {
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
arr.forEach((item) => {
|
|
15
|
-
item.unwatch();
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
}
|