swico 2.5.0 → 2.6.0-beta.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/package.json +2 -1
- package/src/command/build.js +11 -11
- package/src/command/start.js +28 -28
- package/src/index.d.ts +1 -1
- package/src/index.react.d.ts +1 -1
- package/src/index.vue.d.ts +3 -3
- package/src/index.vue.js +7 -7
- package/src/{utils/config.d.ts → main-config/index.d.ts} +1 -1
- package/src/{utils/config.js → main-config/index.js} +37 -18
- package/src/project-path/.swico-react/$env/config.d.ts +1 -1
- package/src/project-path/.swico-vue/$env/config.d.ts +1 -1
- package/src/project-path/.swico-vue/$env/index.js +14 -3
- package/src/{config → rspack-config}/rsbpack.dev.d.ts +1 -1
- package/src/{config → rspack-config}/rsbpack.dev.js +5 -5
- package/src/{config → rspack-config}/rspack.base.react.d.ts +1 -1
- package/src/{config → rspack-config}/rspack.base.react.js +15 -17
- package/src/{config → rspack-config}/rspack.base.vue.d.ts +1 -1
- package/src/{config → rspack-config}/rspack.base.vue.js +14 -21
- package/src/{config → rspack-config}/rspack.prod.d.ts +1 -1
- package/src/{config → rspack-config}/rspack.prod.js +3 -3
- package/src/{utils/tools.d.ts → utils.d.ts} +0 -2
- package/src/{utils/tools.js → utils.js} +1 -25
- package/src/project-path/.swico-vue/Container.d.ts +0 -4
- package/src/project-path/.swico-vue/Container.js +0 -15
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "swico",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.0-beta.10",
|
|
4
4
|
"description": "Simple, efficient, and practical front-end framework",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"types": "./src/index.d.ts",
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
"eslint-rspack-plugin": "4.2.1",
|
|
40
40
|
"fs-extra": "11.3.0",
|
|
41
41
|
"html-loader": "5.1.0",
|
|
42
|
+
"html-webpack-plugin": "5.6.4",
|
|
42
43
|
"less": "4.3.0",
|
|
43
44
|
"less-loader": "12.2.0",
|
|
44
45
|
"ora": "5.4.1",
|
package/src/command/build.js
CHANGED
|
@@ -13,17 +13,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.default = default_1;
|
|
16
|
-
const rspack_prod_1 = __importDefault(require("../config/rspack.prod"));
|
|
17
|
-
const
|
|
18
|
-
const
|
|
16
|
+
const rspack_prod_1 = __importDefault(require("../rspack-config/rspack.prod"));
|
|
17
|
+
const main_config_1 = require("../main-config");
|
|
18
|
+
const utils_1 = require("../utils");
|
|
19
19
|
const package_json_1 = __importDefault(require("../../package.json"));
|
|
20
20
|
const core_1 = require("@rspack/core");
|
|
21
21
|
function default_1() {
|
|
22
22
|
return __awaiter(this, void 0, void 0, function* () {
|
|
23
23
|
process.env.SWICO_ENV = 'prod';
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const projectConfig = yield (0,
|
|
24
|
+
utils_1.toast.info(`Swico v${package_json_1.default.version}`);
|
|
25
|
+
utils_1.toast.info('Initializing production config...');
|
|
26
|
+
const projectConfig = yield (0, main_config_1.getProjectConfig)('prod');
|
|
27
27
|
const { entryPath, templatePath, projectPath, customConfig, templateType } = projectConfig;
|
|
28
28
|
const buildConfig = yield (0, rspack_prod_1.default)({
|
|
29
29
|
entryPath,
|
|
@@ -33,24 +33,24 @@ function default_1() {
|
|
|
33
33
|
templateType
|
|
34
34
|
});
|
|
35
35
|
const compiler = (0, core_1.rspack)(buildConfig);
|
|
36
|
-
|
|
36
|
+
utils_1.toast.info('Building...');
|
|
37
37
|
const now = Date.now();
|
|
38
38
|
compiler.run((err, stats) => {
|
|
39
39
|
if (err) {
|
|
40
|
-
|
|
40
|
+
utils_1.toast.error(err.stack || err.toString());
|
|
41
41
|
return;
|
|
42
42
|
}
|
|
43
43
|
if (stats.hasErrors()) {
|
|
44
44
|
const info = stats.toJson();
|
|
45
|
-
|
|
45
|
+
utils_1.toast.error(info.errors.map((item) => item.stack || item.message));
|
|
46
46
|
return;
|
|
47
47
|
}
|
|
48
48
|
if (stats.hasWarnings()) {
|
|
49
49
|
const info = stats.toJson();
|
|
50
|
-
|
|
50
|
+
utils_1.toast.warning(info.warnings.map((item) => item.stack || item.message));
|
|
51
51
|
}
|
|
52
52
|
const duration = Date.now() - now;
|
|
53
|
-
|
|
53
|
+
utils_1.toast.success(`Build complete in ${(duration / 1000).toFixed(2)}s`);
|
|
54
54
|
});
|
|
55
55
|
});
|
|
56
56
|
}
|
package/src/command/start.js
CHANGED
|
@@ -13,13 +13,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.default = start;
|
|
16
|
-
const rsbpack_dev_1 = __importDefault(require("../config/rsbpack.dev"));
|
|
17
|
-
const
|
|
18
|
-
const
|
|
16
|
+
const rsbpack_dev_1 = __importDefault(require("../rspack-config/rsbpack.dev"));
|
|
17
|
+
const utils_1 = require("../utils");
|
|
18
|
+
const main_config_1 = require("../main-config");
|
|
19
19
|
const chokidar_1 = __importDefault(require("chokidar"));
|
|
20
20
|
const cross_spawn_1 = __importDefault(require("cross-spawn"));
|
|
21
21
|
const path_1 = __importDefault(require("path"));
|
|
22
|
-
const {
|
|
22
|
+
const { SWICO_DEV_PORT, SWICO_DEV_RESTART, SWICO_DEV_ROUTER_BASE } = process.env;
|
|
23
23
|
const package_json_1 = __importDefault(require("../../package.json"));
|
|
24
24
|
const chalk_1 = __importDefault(require("chalk"));
|
|
25
25
|
const dev_server_1 = require("@rspack/dev-server");
|
|
@@ -36,7 +36,7 @@ const handleWatch = (projectPath, devServer, env) => {
|
|
|
36
36
|
ignored: [path_1.default.join(projectPath, '/config/swico.prod.ts')]
|
|
37
37
|
})
|
|
38
38
|
.on('all', (path, stats) => __awaiter(void 0, void 0, void 0, function* () {
|
|
39
|
-
|
|
39
|
+
utils_1.toast.warning('Configuration files changed, restarting server...', {
|
|
40
40
|
inline: true
|
|
41
41
|
});
|
|
42
42
|
yield devServer.stop();
|
|
@@ -65,28 +65,28 @@ const handleWatch = (projectPath, devServer, env) => {
|
|
|
65
65
|
restartServer();
|
|
66
66
|
break;
|
|
67
67
|
case globalStyleFilesPathList.includes(filePath):
|
|
68
|
-
replaceIndexText = (0,
|
|
69
|
-
yield (0,
|
|
68
|
+
replaceIndexText = (0, main_config_1.handleGlobalStyleFile)(replaceIndexText);
|
|
69
|
+
yield (0, main_config_1.updateIndexFileText)(envPath, replaceIndexText);
|
|
70
70
|
break;
|
|
71
71
|
case filePath === loadingFilePath:
|
|
72
|
-
replaceIndexText = yield (0,
|
|
73
|
-
yield (0,
|
|
72
|
+
replaceIndexText = yield (0, main_config_1.handleLoadingFile)(projectPath, replaceIndexText);
|
|
73
|
+
yield (0, main_config_1.updateIndexFileText)(envPath, replaceIndexText);
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
}));
|
|
77
77
|
};
|
|
78
78
|
const restartServer = () => {
|
|
79
79
|
const result = cross_spawn_1.default.sync('cross-env', [
|
|
80
|
-
'
|
|
81
|
-
`
|
|
82
|
-
`
|
|
80
|
+
'SWICO_DEV_RESTART=true',
|
|
81
|
+
`SWICO_DEV_PORT=${currentPort}`,
|
|
82
|
+
`SWICO_DEV_ROUTER_BASE=${currentRouterBase}`,
|
|
83
83
|
'swico',
|
|
84
84
|
'start'
|
|
85
85
|
], {
|
|
86
86
|
stdio: 'inherit'
|
|
87
87
|
});
|
|
88
88
|
if (result.error) {
|
|
89
|
-
|
|
89
|
+
utils_1.toast.error(result.error.message);
|
|
90
90
|
process.exit(1);
|
|
91
91
|
}
|
|
92
92
|
};
|
|
@@ -110,12 +110,12 @@ const createCompileListener = (compiler) => {
|
|
|
110
110
|
let now = Date.now();
|
|
111
111
|
compiler.hooks.beforeCompile.tap('beforeCompile', () => {
|
|
112
112
|
now = Date.now();
|
|
113
|
-
|
|
113
|
+
utils_1.toast.info('Compiling...');
|
|
114
114
|
});
|
|
115
115
|
compiler.hooks.done.tap('done', (stats) => {
|
|
116
116
|
if (stats === null || stats === void 0 ? void 0 : stats.hasErrors()) {
|
|
117
117
|
const info = stats === null || stats === void 0 ? void 0 : stats.toJson();
|
|
118
|
-
|
|
118
|
+
utils_1.toast.error(info === null || info === void 0 ? void 0 : info.errors.map((item) => item.message || item.stack).filter((item1) => !filterStyleFileList.find((item2) => item1.includes(item2))));
|
|
119
119
|
return;
|
|
120
120
|
}
|
|
121
121
|
if (stats === null || stats === void 0 ? void 0 : stats.hasWarnings()) {
|
|
@@ -124,27 +124,27 @@ const createCompileListener = (compiler) => {
|
|
|
124
124
|
warnings.some((item) => {
|
|
125
125
|
const msg = item.message || item.stack;
|
|
126
126
|
if (msg.includes('[eslint]')) {
|
|
127
|
-
|
|
127
|
+
utils_1.toast.warning(msg, { title: 'ESLint errors' });
|
|
128
128
|
return;
|
|
129
129
|
}
|
|
130
130
|
});
|
|
131
131
|
}
|
|
132
132
|
const duration = Date.now() - now;
|
|
133
|
-
|
|
133
|
+
utils_1.toast.info(`Compiled ${duration ? `in ${(duration / 1000).toFixed(2)}s` : ''}`);
|
|
134
134
|
});
|
|
135
135
|
};
|
|
136
136
|
function start() {
|
|
137
137
|
return __awaiter(this, void 0, void 0, function* () {
|
|
138
138
|
var _a, _b, _c, _d, _e, _f;
|
|
139
139
|
process.env.SWICO_ENV = 'dev';
|
|
140
|
-
if (
|
|
140
|
+
if (SWICO_DEV_RESTART !== 'true') {
|
|
141
141
|
console.log('\n');
|
|
142
|
-
|
|
143
|
-
|
|
142
|
+
utils_1.toast.info(`Swico v${package_json_1.default.version}`);
|
|
143
|
+
utils_1.toast.info('Initializing development config...');
|
|
144
144
|
}
|
|
145
|
-
const availablePort =
|
|
146
|
-
const projectConfig = yield (0,
|
|
147
|
-
const { projectPath, customConfig, env } = projectConfig;
|
|
145
|
+
const availablePort = SWICO_DEV_RESTART === 'true' ? Number(SWICO_DEV_PORT) : yield (0, utils_1.getPort)();
|
|
146
|
+
const projectConfig = yield (0, main_config_1.getProjectConfig)('dev');
|
|
147
|
+
const { projectPath, customConfig, env, templateType } = projectConfig;
|
|
148
148
|
const newRouterBase = (_f = (_c = (_b = (_a = customConfig['dev']) === null || _a === void 0 ? void 0 : _a.router) === null || _b === void 0 ? void 0 : _b.base) !== null && _c !== void 0 ? _c : (_e = (_d = customConfig['base']) === null || _d === void 0 ? void 0 : _d.router) === null || _e === void 0 ? void 0 : _e.base) !== null && _f !== void 0 ? _f : '/';
|
|
149
149
|
const startConfig = yield (0, rsbpack_dev_1.default)(projectConfig);
|
|
150
150
|
const compiler = (0, core_1.rspack)(startConfig);
|
|
@@ -153,13 +153,13 @@ function start() {
|
|
|
153
153
|
const devServer = new dev_server_1.RspackDevServer(Object.assign(Object.assign({}, startConfig.devServer), { port: availablePort }), compiler);
|
|
154
154
|
try {
|
|
155
155
|
yield devServer.start();
|
|
156
|
-
process.env.
|
|
156
|
+
process.env.SWICO_DEV_PORT = availablePort.toString();
|
|
157
157
|
createCompileListener(compiler);
|
|
158
158
|
compiler.getInfrastructureLogger = oriLogger;
|
|
159
159
|
handleWatch(projectPath, devServer, env);
|
|
160
|
-
if (
|
|
161
|
-
(
|
|
162
|
-
|
|
160
|
+
if (SWICO_DEV_RESTART !== 'true' ||
|
|
161
|
+
(SWICO_DEV_RESTART === 'true' && newRouterBase !== SWICO_DEV_ROUTER_BASE)) {
|
|
162
|
+
utils_1.toast.info(`Project is running at:${chalk_1.default.hex('#29abe0')(`${startConfig.devServer.server}://localhost:${availablePort}${newRouterBase}`)}`);
|
|
163
163
|
}
|
|
164
164
|
currentRouterBase = newRouterBase;
|
|
165
165
|
currentPort = availablePort;
|
|
@@ -167,7 +167,7 @@ function start() {
|
|
|
167
167
|
catch (e) {
|
|
168
168
|
const strErr = e.toString();
|
|
169
169
|
if (!filterStyleFileList.find((item) => strErr.includes(item))) {
|
|
170
|
-
|
|
170
|
+
utils_1.toast.error(strErr);
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
173
|
});
|
package/src/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GlobalData, GlobalSwicoConfigType } from './
|
|
1
|
+
import { GlobalData, GlobalSwicoConfigType } from './main-config';
|
|
2
2
|
import { UseLocationType, UseNavType } from './typings/global-type';
|
|
3
3
|
export type CustomConfigType = GlobalData['customConfig'];
|
|
4
4
|
export type { GlobalSwicoConfigType };
|
package/src/index.react.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GlobalData, GlobalSwicoConfigType } from './
|
|
1
|
+
import { GlobalData, GlobalSwicoConfigType } from './main-config';
|
|
2
2
|
export type CustomConfigType = GlobalData['customConfig'];
|
|
3
3
|
export type { GlobalSwicoConfigType };
|
|
4
4
|
export { default as Link } from './project-path/.swico-react/Link';
|
package/src/index.vue.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { GlobalData, GlobalSwicoConfigType } from './
|
|
1
|
+
import { GlobalData, GlobalSwicoConfigType } from './main-config';
|
|
2
2
|
import { App } from 'vue';
|
|
3
3
|
import { Router } from 'vue-router';
|
|
4
4
|
export type CustomConfigType = GlobalData['customConfig'];
|
|
5
|
-
export { RouterView
|
|
5
|
+
export { RouterView } from 'vue-router';
|
|
6
6
|
export { useLocation, useNav } from './project-path/.swico-vue/hooks';
|
|
7
7
|
export { history } from './mock-history';
|
|
8
8
|
export type { GlobalSwicoConfigType };
|
|
9
|
-
export {
|
|
9
|
+
export declare const Outlet: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
10
10
|
export interface DefineSwicoConfigType {
|
|
11
11
|
(env: 'base', config: CustomConfigType['base']): any;
|
|
12
12
|
(env: 'dev', config: CustomConfigType['dev']): any;
|
package/src/index.vue.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.defineGlobal = exports.defineConfig = exports.
|
|
3
|
+
exports.defineGlobal = exports.defineConfig = exports.Outlet = exports.history = exports.useNav = exports.useLocation = exports.RouterView = void 0;
|
|
4
|
+
const vue_1 = require("vue");
|
|
7
5
|
var vue_router_1 = require("vue-router");
|
|
8
|
-
Object.defineProperty(exports, "
|
|
6
|
+
Object.defineProperty(exports, "RouterView", { enumerable: true, get: function () { return vue_router_1.RouterView; } });
|
|
9
7
|
var hooks_1 = require("./project-path/.swico-vue/hooks");
|
|
10
8
|
Object.defineProperty(exports, "useLocation", { enumerable: true, get: function () { return hooks_1.useLocation; } });
|
|
11
9
|
Object.defineProperty(exports, "useNav", { enumerable: true, get: function () { return hooks_1.useNav; } });
|
|
12
10
|
var mock_history_1 = require("./mock-history");
|
|
13
11
|
Object.defineProperty(exports, "history", { enumerable: true, get: function () { return mock_history_1.history; } });
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
exports.Outlet = (0, vue_1.defineComponent)({
|
|
13
|
+
name: 'Outlet',
|
|
14
|
+
template: '<RouterView v-slot="{ Component }"><template v-if="Component"><Suspense><component :is="Component"></component><template #fallback></template></Suspense></template></RouterView>'
|
|
15
|
+
});
|
|
16
16
|
const defineConfig = (env, config) => config;
|
|
17
17
|
exports.defineConfig = defineConfig;
|
|
18
18
|
const defineGlobal = (config) => config;
|
|
@@ -44,7 +44,7 @@ export interface GlobalData {
|
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
46
|
export declare const getProjectConfig: (env: GlobalData['env']) => Promise<GlobalData>;
|
|
47
|
-
export declare const handleLoadingFile: (
|
|
47
|
+
export declare const handleLoadingFile: (projectPath: any, replaceIndexText: any) => Promise<any>;
|
|
48
48
|
export declare const handleGlobalStyleFile: (replaceIndexText: any) => any;
|
|
49
49
|
export declare const updateIndexFileText: (envPath: any, newFileText: any) => Promise<void>;
|
|
50
50
|
export declare const getFormatDefineVars: (defineVarsConfigData: any) => Promise<{}>;
|
|
@@ -49,7 +49,30 @@ exports.initConfig = exports.getFormatDefineVars = exports.updateIndexFileText =
|
|
|
49
49
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
50
50
|
const path_1 = __importDefault(require("path"));
|
|
51
51
|
const chalk_1 = __importDefault(require("chalk"));
|
|
52
|
-
const
|
|
52
|
+
const utils_1 = require("../utils");
|
|
53
|
+
const getFormatRouter = (projectPath, routes, templateType) => {
|
|
54
|
+
const _main = (item) => {
|
|
55
|
+
const { component, name, children, redirect, decorator } = item;
|
|
56
|
+
return decorator
|
|
57
|
+
? Object.assign(Object.assign({}, item), { component: `()=>import('${projectPath}/src/pages/${decorator}${templateType === 'vue' ? '.vue' : ''}')`, children: [
|
|
58
|
+
{
|
|
59
|
+
path: '',
|
|
60
|
+
component: component
|
|
61
|
+
? `()=>import('${projectPath}/src/pages/${component}${templateType === 'vue' ? '.vue' : ''}')`
|
|
62
|
+
: undefined,
|
|
63
|
+
name,
|
|
64
|
+
redirect,
|
|
65
|
+
children: children ? children === null || children === void 0 ? void 0 : children.map((item) => _main(item)) : undefined
|
|
66
|
+
}
|
|
67
|
+
] }) : Object.assign(Object.assign({}, item), { component: component
|
|
68
|
+
? `()=>import('${projectPath}/src/pages/${component}${templateType === 'vue' ? '.vue' : ''}')`
|
|
69
|
+
: undefined, name,
|
|
70
|
+
redirect, children: children ? children === null || children === void 0 ? void 0 : children.map((item) => _main(item)) : undefined });
|
|
71
|
+
};
|
|
72
|
+
return routes.map((item) => {
|
|
73
|
+
return _main(item);
|
|
74
|
+
});
|
|
75
|
+
};
|
|
53
76
|
const getProjectConfig = (env) => __awaiter(void 0, void 0, void 0, function* () {
|
|
54
77
|
var _a, _b;
|
|
55
78
|
const projectPath = process.cwd();
|
|
@@ -96,19 +119,19 @@ const getProjectConfig = (env) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
96
119
|
supportedFieldList = ['plugins', 'console', 'copy', 'devtool', 'router'];
|
|
97
120
|
configFileName = 'swico.prod.ts';
|
|
98
121
|
}
|
|
99
|
-
const toastTitle = `Swico config file => ${chalk_1.default.hex(
|
|
122
|
+
const toastTitle = `Swico config file => ${chalk_1.default.hex(utils_1.colorConfig.theme)(configFileName)}`;
|
|
100
123
|
const unSupportedField = configFields.find((field) => !supportedFieldList.includes(field));
|
|
101
124
|
if (configFields.length > 0 && unSupportedField) {
|
|
102
125
|
const msgText = `The Swico configuration file '${chalk_1.default.blue(configFileName)}' does not support the field '${chalk_1.default.red(unSupportedField)}' `;
|
|
103
|
-
|
|
126
|
+
utils_1.toast.error(msgText);
|
|
104
127
|
process.exit(1);
|
|
105
128
|
}
|
|
106
129
|
if (key === 'base' && !['vue', 'react'].includes(configObj['template'])) {
|
|
107
|
-
|
|
130
|
+
utils_1.toast.error(`The field '${chalk_1.default.blue('template')}' does not support the value '${chalk_1.default.red(configObj['template'])}',the value should be 'vue' or 'react' `, { title: toastTitle });
|
|
108
131
|
process.exit(1);
|
|
109
132
|
}
|
|
110
133
|
if (!['hash', 'browser'].includes((_b = (_a = configObj['router']) === null || _a === void 0 ? void 0 : _a.type) !== null && _b !== void 0 ? _b : exports.initConfig.router.type)) {
|
|
111
|
-
|
|
134
|
+
utils_1.toast.error(`The field '${chalk_1.default.blue('router.type')}' does not support the value '${chalk_1.default.red(configObj['router'].type)}',the value should be 'browser' or 'hash' `, { title: toastTitle });
|
|
112
135
|
process.exit(1);
|
|
113
136
|
}
|
|
114
137
|
customConfig[key] = (yield Promise.resolve(`${curConfigFilePath}`).then(s => __importStar(require(s)))).default;
|
|
@@ -152,7 +175,7 @@ const formatRouterConfig = ({ routes = [], type = 'browser', base = '/' }, templ
|
|
|
152
175
|
const projectPath = process.cwd();
|
|
153
176
|
const envPath = env === 'dev' ? '/.dev/' : '/.prod/';
|
|
154
177
|
return new Promise((resolve, reject) => __awaiter(void 0, void 0, void 0, function* () {
|
|
155
|
-
const formatRouter =
|
|
178
|
+
const formatRouter = getFormatRouter(projectPath, routes, templateType);
|
|
156
179
|
const textData = `"use strict";
|
|
157
180
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
158
181
|
exports.default = ${JSON.stringify(formatRouter)};`;
|
|
@@ -198,15 +221,14 @@ const getGlobalStyleFilePath = () => {
|
|
|
198
221
|
}
|
|
199
222
|
return { filePath, fileType };
|
|
200
223
|
};
|
|
201
|
-
const handleLoadingFile = (
|
|
202
|
-
const projectPath = process.cwd();
|
|
224
|
+
const handleLoadingFile = (projectPath, replaceIndexText) => __awaiter(void 0, void 0, void 0, function* () {
|
|
203
225
|
let newReplaceIndexText = replaceIndexText;
|
|
204
226
|
try {
|
|
205
227
|
yield fs_extra_1.default.access(path_1.default.resolve(projectPath, './src/loading/index.tsx'), fs_extra_1.default.constants.F_OK);
|
|
206
|
-
newReplaceIndexText = newReplaceIndexText.replace('"../loading"', '"../../src/loading
|
|
228
|
+
newReplaceIndexText = newReplaceIndexText.replace('"../loading"', '"../../src/loading');
|
|
207
229
|
}
|
|
208
230
|
catch (e) {
|
|
209
|
-
newReplaceIndexText = newReplaceIndexText.replace('"../../src/loading
|
|
231
|
+
newReplaceIndexText = newReplaceIndexText.replace('"../../src/loading', '"../loading"');
|
|
210
232
|
}
|
|
211
233
|
return newReplaceIndexText;
|
|
212
234
|
});
|
|
@@ -234,8 +256,8 @@ const initTemplateConfig = (routerConfig, templateType, env) => {
|
|
|
234
256
|
const envPath = env === 'dev' ? '/.dev/' : '/.prod/';
|
|
235
257
|
return new Promise((resolve, reject) => __awaiter(void 0, void 0, void 0, function* () {
|
|
236
258
|
const copyTargetPath = path_1.default.resolve(projectPath, `./.swico${envPath}`);
|
|
237
|
-
yield (0,
|
|
238
|
-
yield (0,
|
|
259
|
+
yield (0, utils_1.copyDirFiles)(path_1.default.resolve(__dirname, `../project-path/.swico-${templateType}/$env`), copyTargetPath, (fileName) => !fileName.endsWith('.d.ts') && !['hooks.js'].includes(fileName));
|
|
260
|
+
yield (0, utils_1.copyDirFiles)(path_1.default.resolve(__dirname, `../project-path/.swico-${templateType}`), path_1.default.resolve(projectPath, './.swico'), (fileName) => ['hooks.js', 'Link.js', 'loading.js'].includes(fileName));
|
|
239
261
|
const entryFilePath = path_1.default.resolve(projectPath, './.swico/index.js');
|
|
240
262
|
yield fs_extra_1.default.copyFile(path_1.default.resolve(__dirname, `../index.${templateType}.js`), entryFilePath);
|
|
241
263
|
yield formatRouterConfig(routerConfig, templateType, env);
|
|
@@ -245,13 +267,10 @@ const initTemplateConfig = (routerConfig, templateType, env) => {
|
|
|
245
267
|
yield fs_extra_1.default.writeFile(hooksFilePath, replaceHooksText);
|
|
246
268
|
let replaceIndexText = yield fs_extra_1.default.readFile(path_1.default.resolve(projectPath, `./.swico${envPath}index.js`), 'utf8');
|
|
247
269
|
replaceIndexText = (0, exports.handleGlobalStyleFile)(replaceIndexText);
|
|
248
|
-
if (templateType === '
|
|
249
|
-
yield (0, exports.
|
|
250
|
-
}
|
|
251
|
-
else if (templateType === 'react') {
|
|
252
|
-
const newReplaceIndexText = yield (0, exports.handleLoadingFile)(replaceIndexText, envPath);
|
|
253
|
-
yield (0, exports.updateIndexFileText)(envPath, newReplaceIndexText);
|
|
270
|
+
if (templateType === 'react') {
|
|
271
|
+
replaceIndexText = yield (0, exports.handleLoadingFile)(projectPath, replaceIndexText);
|
|
254
272
|
}
|
|
273
|
+
yield (0, exports.updateIndexFileText)(envPath, replaceIndexText);
|
|
255
274
|
resolve(null);
|
|
256
275
|
}));
|
|
257
276
|
};
|
|
@@ -5,13 +5,24 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
var _a;
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
const vue_1 = require("vue");
|
|
8
|
-
const Container_1 = __importDefault(require("../Container"));
|
|
9
8
|
const Layout_1 = __importDefault(require("../../src/layout/Layout"));
|
|
10
9
|
const global_1 = __importDefault(require("../../src/global"));
|
|
11
10
|
const history_1 = require("./history");
|
|
11
|
+
const Container = (0, vue_1.defineComponent)({
|
|
12
|
+
name: 'Container',
|
|
13
|
+
setup(props) {
|
|
14
|
+
const error = (0, vue_1.ref)(null);
|
|
15
|
+
(0, vue_1.onErrorCaptured)((err) => {
|
|
16
|
+
error.value = err.toString();
|
|
17
|
+
return false;
|
|
18
|
+
});
|
|
19
|
+
return { error };
|
|
20
|
+
},
|
|
21
|
+
template: '<SwicoLayout v-if="!error"></SwicoLayout>'
|
|
22
|
+
});
|
|
12
23
|
const router = (0, history_1.getRouter)();
|
|
13
|
-
const app = (0, vue_1.createApp)(
|
|
14
|
-
app.component('
|
|
24
|
+
const app = (0, vue_1.createApp)(Container);
|
|
25
|
+
app.component('SwicoLayout', Layout_1.default);
|
|
15
26
|
app.use(router);
|
|
16
27
|
(_a = global_1.default === null || global_1.default === void 0 ? void 0 : global_1.default.onInit) === null || _a === void 0 ? void 0 : _a.call(global_1.default, app, router);
|
|
17
28
|
app.mount('#root');
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { GlobalData } from '../
|
|
1
|
+
import { GlobalData } from '../main-config';
|
|
2
2
|
export default function (options: GlobalData): Promise<any>;
|
|
@@ -46,12 +46,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
46
46
|
};
|
|
47
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
48
|
exports.default = default_1;
|
|
49
|
-
const
|
|
49
|
+
const main_config_1 = require("../main-config");
|
|
50
50
|
const path_1 = __importDefault(require("path"));
|
|
51
51
|
const webpack_merge_1 = require("webpack-merge");
|
|
52
52
|
const eslint_rspack_plugin_1 = __importDefault(require("eslint-rspack-plugin"));
|
|
53
53
|
const ts_checker_rspack_plugin_1 = require("ts-checker-rspack-plugin");
|
|
54
|
-
const
|
|
54
|
+
const utils_1 = require("../utils");
|
|
55
55
|
function default_1(options) {
|
|
56
56
|
return __awaiter(this, void 0, void 0, function* () {
|
|
57
57
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
@@ -74,8 +74,8 @@ function default_1(options) {
|
|
|
74
74
|
progress: false,
|
|
75
75
|
overlay: false
|
|
76
76
|
},
|
|
77
|
-
headers: (_c = (_b = customConfig === null || customConfig === void 0 ? void 0 : customConfig.dev) === null || _b === void 0 ? void 0 : _b.responseHeaders) !== null && _c !== void 0 ? _c :
|
|
78
|
-
proxy: (_e = (_d = customConfig === null || customConfig === void 0 ? void 0 : customConfig.dev) === null || _d === void 0 ? void 0 : _d.proxy) !== null && _e !== void 0 ? _e :
|
|
77
|
+
headers: (_c = (_b = customConfig === null || customConfig === void 0 ? void 0 : customConfig.dev) === null || _b === void 0 ? void 0 : _b.responseHeaders) !== null && _c !== void 0 ? _c : main_config_1.initConfig.responseHeaders,
|
|
78
|
+
proxy: (_e = (_d = customConfig === null || customConfig === void 0 ? void 0 : customConfig.dev) === null || _d === void 0 ? void 0 : _d.proxy) !== null && _e !== void 0 ? _e : main_config_1.initConfig.proxy,
|
|
79
79
|
compress: true,
|
|
80
80
|
hot: true,
|
|
81
81
|
open: false,
|
|
@@ -90,7 +90,7 @@ function default_1(options) {
|
|
|
90
90
|
logger: {
|
|
91
91
|
log: () => { },
|
|
92
92
|
error: (message) => {
|
|
93
|
-
|
|
93
|
+
utils_1.toast.error(message, { title: 'TypeScript errors' });
|
|
94
94
|
}
|
|
95
95
|
},
|
|
96
96
|
typescript: {
|
|
@@ -14,14 +14,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.default = default_1;
|
|
16
16
|
const path_1 = __importDefault(require("path"));
|
|
17
|
-
const
|
|
17
|
+
const main_config_1 = require("../main-config");
|
|
18
18
|
const core_1 = require("@rspack/core");
|
|
19
|
+
const html_webpack_plugin_1 = __importDefault(require("html-webpack-plugin"));
|
|
19
20
|
const lessLoader = require.resolve('less-loader');
|
|
20
21
|
const sassLoader = require.resolve('sass-loader');
|
|
21
22
|
const postcssLoader = require.resolve('postcss-loader');
|
|
22
23
|
function default_1(_a) {
|
|
23
24
|
return __awaiter(this, arguments, void 0, function* ({ projectPath, entryPath, env, customConfig }) {
|
|
24
|
-
var _b, _c, _d, _e, _f
|
|
25
|
+
var _b, _c, _d, _e, _f;
|
|
25
26
|
const customBaseConfig = customConfig.base;
|
|
26
27
|
const getCustomAliasConfig = () => {
|
|
27
28
|
const { alias } = customBaseConfig || {};
|
|
@@ -33,14 +34,14 @@ function default_1(_a) {
|
|
|
33
34
|
}
|
|
34
35
|
return custAliasConfig;
|
|
35
36
|
};
|
|
36
|
-
const publicPath = (_b = customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.publicPath) !== null && _b !== void 0 ? _b :
|
|
37
|
-
const routerBase = (_d = (_c = customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.router) === null || _c === void 0 ? void 0 : _c.base) !== null && _d !== void 0 ? _d :
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
37
|
+
const publicPath = (_b = customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.publicPath) !== null && _b !== void 0 ? _b : main_config_1.initConfig.publicPath;
|
|
38
|
+
const routerBase = (_d = (_c = customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.router) === null || _c === void 0 ? void 0 : _c.base) !== null && _d !== void 0 ? _d : main_config_1.initConfig.router.base;
|
|
39
|
+
const initialDefineVarsConfig = {
|
|
40
|
+
SWICO_ENV: JSON.stringify(env),
|
|
41
|
+
SWICO_ROUTER_BASE: JSON.stringify(routerBase),
|
|
42
|
+
SWICO_PUBLIC_PATH: JSON.stringify(publicPath)
|
|
43
|
+
};
|
|
44
|
+
const customDefineVarsConfig = yield (0, main_config_1.getFormatDefineVars)((_e = customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.define) !== null && _e !== void 0 ? _e : {});
|
|
44
45
|
return {
|
|
45
46
|
entry: entryPath,
|
|
46
47
|
output: {
|
|
@@ -149,18 +150,15 @@ function default_1(_a) {
|
|
|
149
150
|
},
|
|
150
151
|
externals: customConfig.base.externals,
|
|
151
152
|
plugins: [
|
|
152
|
-
|
|
153
|
-
new core_1.rspack.HtmlRspackPlugin({
|
|
153
|
+
new html_webpack_plugin_1.default({
|
|
154
154
|
template: path_1.default.join(projectPath, '/src/index.ejs'),
|
|
155
155
|
filename: 'index.html',
|
|
156
156
|
minify: true,
|
|
157
|
-
templateParameters:
|
|
158
|
-
publicPath,
|
|
159
|
-
routerBase
|
|
160
|
-
},
|
|
157
|
+
templateParameters: initialDefineVarsConfig,
|
|
161
158
|
hash: true
|
|
162
159
|
}),
|
|
163
|
-
|
|
160
|
+
new core_1.rspack.DefinePlugin(Object.assign(Object.assign({}, initialDefineVarsConfig), customDefineVarsConfig)),
|
|
161
|
+
...((_f = customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.plugins) !== null && _f !== void 0 ? _f : main_config_1.initConfig.plugins)
|
|
164
162
|
]
|
|
165
163
|
};
|
|
166
164
|
});
|
|
@@ -14,9 +14,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.default = default_1;
|
|
16
16
|
const path_1 = __importDefault(require("path"));
|
|
17
|
-
const
|
|
17
|
+
const main_config_1 = require("../main-config");
|
|
18
18
|
const vue_loader_1 = require("vue-loader");
|
|
19
19
|
const core_1 = require("@rspack/core");
|
|
20
|
+
const html_webpack_plugin_1 = __importDefault(require("html-webpack-plugin"));
|
|
20
21
|
const vueStyleLoader = require.resolve('vue-style-loader');
|
|
21
22
|
const cssLoader = require.resolve('css-loader');
|
|
22
23
|
const lessLoader = require.resolve('less-loader');
|
|
@@ -36,14 +37,14 @@ function default_1(_a) {
|
|
|
36
37
|
}
|
|
37
38
|
return custAliasConfig;
|
|
38
39
|
};
|
|
39
|
-
const publicPath = (_b = customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.publicPath) !== null && _b !== void 0 ? _b :
|
|
40
|
-
const routerBase = (_d = (_c = customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.router) === null || _c === void 0 ? void 0 : _c.base) !== null && _d !== void 0 ? _d :
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
40
|
+
const publicPath = (_b = customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.publicPath) !== null && _b !== void 0 ? _b : main_config_1.initConfig.publicPath;
|
|
41
|
+
const routerBase = (_d = (_c = customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.router) === null || _c === void 0 ? void 0 : _c.base) !== null && _d !== void 0 ? _d : main_config_1.initConfig.router.base;
|
|
42
|
+
const initialDefineVarsConfig = {
|
|
43
|
+
SWICO_ENV: JSON.stringify(env),
|
|
44
|
+
SWICO_ROUTER_BASE: JSON.stringify(routerBase),
|
|
45
|
+
SWICO_PUBLIC_PATH: JSON.stringify(publicPath)
|
|
46
|
+
};
|
|
47
|
+
const customDefineVarsConfig = yield (0, main_config_1.getFormatDefineVars)((_e = customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.define) !== null && _e !== void 0 ? _e : {});
|
|
47
48
|
return {
|
|
48
49
|
entry: entryPath,
|
|
49
50
|
output: {
|
|
@@ -257,28 +258,20 @@ function default_1(_a) {
|
|
|
257
258
|
},
|
|
258
259
|
externals: customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.externals,
|
|
259
260
|
plugins: [
|
|
260
|
-
...basicPlugins,
|
|
261
261
|
new core_1.CssExtractRspackPlugin({
|
|
262
262
|
filename: env === 'dev' ? 'css/[name].css' : 'css/[name].[contenthash].css',
|
|
263
263
|
ignoreOrder: true
|
|
264
264
|
}),
|
|
265
265
|
new vue_loader_1.VueLoaderPlugin(),
|
|
266
|
-
new core_1.DefinePlugin({
|
|
267
|
-
|
|
268
|
-
__VUE_PROD_DEVTOOLS__: false,
|
|
269
|
-
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: false
|
|
270
|
-
}),
|
|
271
|
-
new core_1.HtmlRspackPlugin({
|
|
266
|
+
new core_1.DefinePlugin(Object.assign(Object.assign({ __VUE_OPTIONS_API__: true, __VUE_PROD_DEVTOOLS__: false, __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: false }, initialDefineVarsConfig), customDefineVarsConfig)),
|
|
267
|
+
new html_webpack_plugin_1.default({
|
|
272
268
|
template: path_1.default.join(projectPath, '/src/index.ejs'),
|
|
273
269
|
filename: 'index.html',
|
|
274
270
|
minify: true,
|
|
275
|
-
templateParameters:
|
|
276
|
-
publicPath,
|
|
277
|
-
routerBase
|
|
278
|
-
},
|
|
271
|
+
templateParameters: initialDefineVarsConfig,
|
|
279
272
|
hash: true
|
|
280
273
|
}),
|
|
281
|
-
...((_f = customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.plugins) !== null && _f !== void 0 ? _f :
|
|
274
|
+
...((_f = customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.plugins) !== null && _f !== void 0 ? _f : main_config_1.initConfig.plugins)
|
|
282
275
|
]
|
|
283
276
|
};
|
|
284
277
|
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { GlobalData } from '../
|
|
1
|
+
import { GlobalData } from '../main-config';
|
|
2
2
|
export default function (options: GlobalData): Promise<any>;
|
|
@@ -49,7 +49,7 @@ exports.default = default_1;
|
|
|
49
49
|
const webpack_bundle_analyzer_1 = __importDefault(require("webpack-bundle-analyzer"));
|
|
50
50
|
const path_1 = __importDefault(require("path"));
|
|
51
51
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
52
|
-
const
|
|
52
|
+
const main_config_1 = require("../main-config");
|
|
53
53
|
const webpack_merge_1 = require("webpack-merge");
|
|
54
54
|
const core_1 = require("@rspack/core");
|
|
55
55
|
const BundleAnalyzerPlugin = webpack_bundle_analyzer_1.default.BundleAnalyzerPlugin;
|
|
@@ -60,9 +60,9 @@ function default_1(options) {
|
|
|
60
60
|
const { projectPath, customConfig, templateType } = options;
|
|
61
61
|
const getBaseConfig = (yield Promise.resolve(`${templateType === 'vue' ? './rspack.base.vue' : './rspack.base.react'}`).then(s => __importStar(require(s)))).default;
|
|
62
62
|
const baseConfig = yield getBaseConfig(Object.assign(Object.assign({}, options), { env: 'prod' }));
|
|
63
|
-
const consoleAvailable = (_b = (_a = customConfig.prod) === null || _a === void 0 ? void 0 : _a.console) !== null && _b !== void 0 ? _b :
|
|
63
|
+
const consoleAvailable = (_b = (_a = customConfig.prod) === null || _a === void 0 ? void 0 : _a.console) !== null && _b !== void 0 ? _b : main_config_1.initConfig.console;
|
|
64
64
|
const isPublicDirExist = yield fs_extra_1.default.exists(path_1.default.join(projectPath, '/public'));
|
|
65
|
-
const copyConfig = (_d = (_c = customConfig.prod) === null || _c === void 0 ? void 0 : _c.copy) !== null && _d !== void 0 ? _d :
|
|
65
|
+
const copyConfig = (_d = (_c = customConfig.prod) === null || _c === void 0 ? void 0 : _c.copy) !== null && _d !== void 0 ? _d : main_config_1.initConfig.copy;
|
|
66
66
|
const customDevtool = (_e = customConfig.prod.devtool) !== null && _e !== void 0 ? _e : customConfig.base.devtool;
|
|
67
67
|
return (0, webpack_merge_1.merge)(baseConfig, {
|
|
68
68
|
output: {
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { ConfigRouterType } from './config';
|
|
2
1
|
export declare const copyDirFiles: (src: any, dest: any, filter?: (fileName: any) => boolean) => Promise<void>;
|
|
3
|
-
export declare const getFormatRouter: (projectPath: string, routes: ConfigRouterType["routes"], templateType: any) => any[];
|
|
4
2
|
export declare const getPort: () => Promise<number>;
|
|
5
3
|
export declare const colorConfig: {
|
|
6
4
|
theme: string;
|
|
@@ -19,7 +19,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
19
19
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.toast = exports.colorConfig = exports.getPort = exports.
|
|
22
|
+
exports.toast = exports.colorConfig = exports.getPort = exports.copyDirFiles = void 0;
|
|
23
23
|
const portfinder_1 = __importDefault(require("portfinder"));
|
|
24
24
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
25
25
|
const path_1 = __importDefault(require("path"));
|
|
@@ -63,30 +63,6 @@ const copyDirFiles = (src, dest, filter) => __awaiter(void 0, void 0, void 0, fu
|
|
|
63
63
|
yield _copy(src, dest);
|
|
64
64
|
});
|
|
65
65
|
exports.copyDirFiles = copyDirFiles;
|
|
66
|
-
const getFormatRouter = (projectPath, routes, templateType) => {
|
|
67
|
-
const _main = (item) => {
|
|
68
|
-
const { component, name, children, redirect, decorator } = item;
|
|
69
|
-
return decorator
|
|
70
|
-
? Object.assign(Object.assign({}, item), { component: `()=>import('${projectPath}/src/pages/${decorator}${templateType === 'vue' ? '.vue' : ''}')`, children: [
|
|
71
|
-
{
|
|
72
|
-
path: '',
|
|
73
|
-
component: component
|
|
74
|
-
? `()=>import('${projectPath}/src/pages/${component}${templateType === 'vue' ? '.vue' : ''}')`
|
|
75
|
-
: undefined,
|
|
76
|
-
name,
|
|
77
|
-
redirect,
|
|
78
|
-
children: children ? children === null || children === void 0 ? void 0 : children.map((item) => _main(item)) : undefined
|
|
79
|
-
}
|
|
80
|
-
] }) : Object.assign(Object.assign({}, item), { component: component
|
|
81
|
-
? `()=>import('${projectPath}/src/pages/${component}${templateType === 'vue' ? '.vue' : ''}')`
|
|
82
|
-
: undefined, name,
|
|
83
|
-
redirect, children: children ? children === null || children === void 0 ? void 0 : children.map((item) => _main(item)) : undefined });
|
|
84
|
-
};
|
|
85
|
-
return routes.map((item) => {
|
|
86
|
-
return _main(item);
|
|
87
|
-
});
|
|
88
|
-
};
|
|
89
|
-
exports.getFormatRouter = getFormatRouter;
|
|
90
66
|
const getPort = () => {
|
|
91
67
|
return portfinder_1.default.getPortPromise({
|
|
92
68
|
port: 3000,
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
declare const _default: import("vue").DefineComponent<{}, {
|
|
2
|
-
error: import("vue").Ref<string, string>;
|
|
3
|
-
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
4
|
-
export default _default;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const vue_1 = require("vue");
|
|
4
|
-
exports.default = (0, vue_1.defineComponent)({
|
|
5
|
-
name: 'Container',
|
|
6
|
-
setup(props) {
|
|
7
|
-
const error = (0, vue_1.ref)(null);
|
|
8
|
-
(0, vue_1.onErrorCaptured)((err) => {
|
|
9
|
-
error.value = err.toString();
|
|
10
|
-
return false;
|
|
11
|
-
});
|
|
12
|
-
return { error };
|
|
13
|
-
},
|
|
14
|
-
template: '<Layout v-if="!error"><RouterView /></Layout>'
|
|
15
|
-
});
|