swico 2.9.0 → 3.0.0-beta.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/README.md +1 -1
- package/package.json +8 -21
- package/src/command/build.js +12 -11
- package/src/command/start.js +16 -40
- package/src/main-config/index.d.ts +1 -0
- package/src/main-config/index.js +9 -1
- package/src/rsbuild-config/config.base.react.d.ts +3 -0
- package/src/rsbuild-config/config.base.react.js +99 -0
- package/src/rsbuild-config/config.base.vue.d.ts +3 -0
- package/src/rsbuild-config/config.base.vue.js +99 -0
- package/src/rsbuild-config/config.dev.d.ts +3 -0
- package/src/{rspack-config/rsbpack.dev.js → rsbuild-config/config.dev.js} +32 -24
- package/src/rsbuild-config/config.prod.d.ts +3 -0
- package/src/rsbuild-config/config.prod.js +72 -0
- package/src/utils.d.ts +0 -1
- package/src/utils.js +1 -9
- package/src/rspack-config/rsbpack.dev.d.ts +0 -2
- package/src/rspack-config/rspack.base.react.d.ts +0 -100
- package/src/rspack-config/rspack.base.react.js +0 -166
- package/src/rspack-config/rspack.base.vue.d.ts +0 -135
- package/src/rspack-config/rspack.base.vue.js +0 -279
- package/src/rspack-config/rspack.prod.d.ts +0 -2
- package/src/rspack-config/rspack.prod.js +0 -128
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "swico",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-beta.1",
|
|
4
4
|
"description": "Simple, efficient, and practical front-end framework",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"types": "./src/index.d.ts",
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"compile": "tsc && ts-node ./src/task.ts",
|
|
35
35
|
"publish:offical": "npm run compile && cd ./dist && npm publish",
|
|
36
36
|
"publish:beta": "npm run compile && cd ./dist && npm publish --tag=beta",
|
|
37
|
+
"publish:alpha": "npm run compile && cd ./dist && npm publish --tag=alpha",
|
|
37
38
|
"lint:fix": "eslint --fix src/**/*.{js,jsx,ts,tsx} "
|
|
38
39
|
},
|
|
39
40
|
"repository": {
|
|
@@ -43,39 +44,25 @@
|
|
|
43
44
|
"author": "scw",
|
|
44
45
|
"license": "ISC",
|
|
45
46
|
"dependencies": {
|
|
46
|
-
"@
|
|
47
|
-
"@
|
|
47
|
+
"@rsbuild/plugin-basic-ssl": "^1.2.2",
|
|
48
|
+
"@rsbuild/plugin-react": "^1.4.6",
|
|
49
|
+
"@rsbuild/plugin-vue": "^1.2.7",
|
|
48
50
|
"chalk": "4.1.2",
|
|
49
51
|
"chokidar": "3.6.0",
|
|
50
52
|
"commander": "12.0.0",
|
|
51
53
|
"cross-spawn": "7.0.5",
|
|
52
|
-
"
|
|
53
|
-
"eslint-rspack-plugin": "4.2.1",
|
|
54
|
+
"eslint-rspack-plugin": "4.4.1",
|
|
54
55
|
"fs-extra": "11.3.0",
|
|
55
|
-
"html-loader": "5.1.0",
|
|
56
|
-
"html-webpack-plugin": "5.6.4",
|
|
57
|
-
"less": "4.3.0",
|
|
58
|
-
"less-loader": "12.2.0",
|
|
59
56
|
"ora": "5.4.1",
|
|
60
|
-
"portfinder": "1.0.32",
|
|
61
|
-
"postcss": "8.5.3",
|
|
62
|
-
"postcss-loader": "8.1.0",
|
|
63
57
|
"qs": "6.13.0",
|
|
64
58
|
"react-router": "7.5.0",
|
|
65
|
-
"sass-embedded": "1.86.3",
|
|
66
|
-
"sass-loader": "16.0.5",
|
|
67
|
-
"style-loader": "3.3.0",
|
|
68
59
|
"ts-checker-rspack-plugin": "1.1.1",
|
|
69
60
|
"ts-node": "10.9.1",
|
|
70
|
-
"vue-
|
|
71
|
-
"vue-router": "4.5.0",
|
|
72
|
-
"vue-style-loader": "4.1.3",
|
|
73
|
-
"webpack-bundle-analyzer": "4.9.1",
|
|
74
|
-
"webpack-merge": "6.0.1"
|
|
61
|
+
"vue-router": "4.5.0"
|
|
75
62
|
},
|
|
76
63
|
"devDependencies": {
|
|
77
64
|
"@eslint/js": "9.24.0",
|
|
78
|
-
"@
|
|
65
|
+
"@rsbuild/core": "^2.0.0-rc.0",
|
|
79
66
|
"@types/node": "22.13.10",
|
|
80
67
|
"@types/react": "~19.2.0",
|
|
81
68
|
"@types/react-dom": "~19.2.0",
|
package/src/command/build.js
CHANGED
|
@@ -13,11 +13,12 @@ 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
|
|
16
|
+
const config_prod_1 = __importDefault(require("../rsbuild-config/config.prod"));
|
|
17
17
|
const main_config_1 = require("../main-config");
|
|
18
18
|
const utils_1 = require("../utils");
|
|
19
19
|
const package_json_1 = __importDefault(require("../../package.json"));
|
|
20
|
-
const core_1 = require("@
|
|
20
|
+
const core_1 = require("@rsbuild/core");
|
|
21
|
+
const isAnalyze = process.env.ANALYZE === 'true';
|
|
21
22
|
function default_1() {
|
|
22
23
|
return __awaiter(this, void 0, void 0, function* () {
|
|
23
24
|
process.env.SWICO_ENV = 'prod';
|
|
@@ -25,28 +26,28 @@ function default_1() {
|
|
|
25
26
|
utils_1.toast.info('Initializing production config...');
|
|
26
27
|
const projectConfig = yield (0, main_config_1.getProjectConfig)('prod');
|
|
27
28
|
const { entryPath, templatePath, projectPath, customConfig, templateType } = projectConfig;
|
|
28
|
-
const buildConfig = yield (0,
|
|
29
|
+
const buildConfig = yield (0, config_prod_1.default)({
|
|
29
30
|
entryPath,
|
|
30
31
|
templatePath,
|
|
31
32
|
projectPath,
|
|
32
33
|
customConfig,
|
|
33
34
|
templateType
|
|
34
35
|
});
|
|
35
|
-
const
|
|
36
|
+
const rsbuild = yield (0, core_1.createRsbuild)({ config: buildConfig });
|
|
37
|
+
yield rsbuild.build();
|
|
38
|
+
if (isAnalyze) {
|
|
39
|
+
yield rsbuild.preview();
|
|
40
|
+
}
|
|
36
41
|
utils_1.toast.info('Building...');
|
|
37
42
|
const now = Date.now();
|
|
38
|
-
|
|
39
|
-
if (err) {
|
|
40
|
-
utils_1.toast.error(err.stack || err.toString());
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
+
rsbuild.onAfterBuild(({ stats }) => {
|
|
43
44
|
if (stats.hasErrors()) {
|
|
44
|
-
const info = stats.toJson();
|
|
45
|
+
const info = stats.toJson({ all: true });
|
|
45
46
|
utils_1.toast.error(info.errors.map((item) => item.stack || item.message));
|
|
46
47
|
return;
|
|
47
48
|
}
|
|
48
49
|
if (stats.hasWarnings()) {
|
|
49
|
-
const info = stats.toJson();
|
|
50
|
+
const info = stats.toJson({ all: true });
|
|
50
51
|
utils_1.toast.warning(info.warnings.map((item) => item.stack || item.message));
|
|
51
52
|
}
|
|
52
53
|
const duration = Date.now() - now;
|
package/src/command/start.js
CHANGED
|
@@ -13,19 +13,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.default = start;
|
|
16
|
-
const
|
|
16
|
+
const config_dev_1 = __importDefault(require("../rsbuild-config/config.dev"));
|
|
17
17
|
const utils_1 = require("../utils");
|
|
18
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 { SWICO_DEV_PORT, SWICO_DEV_RESTART, SWICO_DEV_ROUTER_BASE } = process.env;
|
|
23
22
|
const package_json_1 = __importDefault(require("../../package.json"));
|
|
24
23
|
const chalk_1 = __importDefault(require("chalk"));
|
|
25
|
-
const dev_server_1 = require("@rspack/dev-server");
|
|
26
24
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
27
|
-
const core_1 = require("@
|
|
28
|
-
|
|
25
|
+
const core_1 = require("@rsbuild/core");
|
|
26
|
+
const { SWICO_DEV_RESTART, SWICO_DEV_ROUTER_BASE } = process.env;
|
|
27
|
+
let currentRouterBase = '/';
|
|
29
28
|
const handleWatch = (projectPath, devServer, env) => {
|
|
30
29
|
const envPath = env === 'dev' ? '/.dev/' : '/.prod/';
|
|
31
30
|
const configFilesWatcher = chokidar_1.default
|
|
@@ -39,7 +38,7 @@ const handleWatch = (projectPath, devServer, env) => {
|
|
|
39
38
|
utils_1.toast.warning('Configuration files changed, restarting server...', {
|
|
40
39
|
inline: true
|
|
41
40
|
});
|
|
42
|
-
yield devServer.
|
|
41
|
+
yield devServer.close();
|
|
43
42
|
yield configFilesWatcher.close();
|
|
44
43
|
restartServer();
|
|
45
44
|
}));
|
|
@@ -60,7 +59,7 @@ const handleWatch = (projectPath, devServer, env) => {
|
|
|
60
59
|
if (['add', 'unlink'].includes(eventName)) {
|
|
61
60
|
switch (true) {
|
|
62
61
|
case filePath.endsWith('.d.ts'):
|
|
63
|
-
yield devServer.
|
|
62
|
+
yield devServer.close();
|
|
64
63
|
yield tsTypingsWatcher.close();
|
|
65
64
|
restartServer();
|
|
66
65
|
break;
|
|
@@ -76,13 +75,7 @@ const handleWatch = (projectPath, devServer, env) => {
|
|
|
76
75
|
}));
|
|
77
76
|
};
|
|
78
77
|
const restartServer = () => {
|
|
79
|
-
const result = cross_spawn_1.default.sync('cross-env', [
|
|
80
|
-
'SWICO_DEV_RESTART=true',
|
|
81
|
-
`SWICO_DEV_PORT=${currentPort}`,
|
|
82
|
-
`SWICO_DEV_ROUTER_BASE=${currentRouterBase}`,
|
|
83
|
-
'swico',
|
|
84
|
-
'start'
|
|
85
|
-
], {
|
|
78
|
+
const result = cross_spawn_1.default.sync('cross-env', ['SWICO_DEV_RESTART=true', `SWICO_DEV_ROUTER_BASE=${currentRouterBase}`, 'swico', 'start'], {
|
|
86
79
|
stdio: 'inherit'
|
|
87
80
|
});
|
|
88
81
|
if (result.error) {
|
|
@@ -90,29 +83,19 @@ const restartServer = () => {
|
|
|
90
83
|
process.exit(1);
|
|
91
84
|
}
|
|
92
85
|
};
|
|
93
|
-
const getMockGetLogger = (compiler) => {
|
|
94
|
-
const logger = compiler.getInfrastructureLogger('name');
|
|
95
|
-
const { log, debug, error, warn } = logger;
|
|
96
|
-
return (name) => {
|
|
97
|
-
return Object.assign(Object.assign({}, logger), { log,
|
|
98
|
-
debug,
|
|
99
|
-
error,
|
|
100
|
-
warn, info: () => { } });
|
|
101
|
-
};
|
|
102
|
-
};
|
|
103
86
|
const filterStyleFileList = [
|
|
104
87
|
"Can't resolve '../../src/global.less'",
|
|
105
88
|
"Can't resolve '../../src/global.css'",
|
|
106
89
|
"Can't resolve '../../src/global.scss'",
|
|
107
90
|
"Can't resolve '../../src/loading'"
|
|
108
91
|
];
|
|
109
|
-
const createCompileListener = (
|
|
92
|
+
const createCompileListener = (rsbuild) => {
|
|
110
93
|
let now = Date.now();
|
|
111
|
-
|
|
94
|
+
rsbuild.onBeforeDevCompile(() => {
|
|
112
95
|
now = Date.now();
|
|
113
96
|
utils_1.toast.info('Compiling...');
|
|
114
97
|
});
|
|
115
|
-
|
|
98
|
+
rsbuild.onAfterDevCompile(({ stats }) => {
|
|
116
99
|
if (stats === null || stats === void 0 ? void 0 : stats.hasErrors()) {
|
|
117
100
|
const info = stats === null || stats === void 0 ? void 0 : stats.toJson();
|
|
118
101
|
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))));
|
|
@@ -142,27 +125,20 @@ function start() {
|
|
|
142
125
|
utils_1.toast.info(`Swico v${package_json_1.default.version}`);
|
|
143
126
|
utils_1.toast.info('Initializing development config...');
|
|
144
127
|
}
|
|
145
|
-
const availablePort = SWICO_DEV_RESTART === 'true' ? Number(SWICO_DEV_PORT) : yield (0, utils_1.getPort)();
|
|
146
128
|
const projectConfig = yield (0, main_config_1.getProjectConfig)('dev');
|
|
147
129
|
const { projectPath, customConfig, env, templateType } = projectConfig;
|
|
148
130
|
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
|
-
const startConfig = yield (0,
|
|
150
|
-
const
|
|
151
|
-
const oriLogger = compiler.getInfrastructureLogger;
|
|
152
|
-
compiler.getInfrastructureLogger = getMockGetLogger(compiler);
|
|
153
|
-
const devServer = new dev_server_1.RspackDevServer(Object.assign(Object.assign({}, startConfig.devServer), { port: availablePort }), compiler);
|
|
131
|
+
const startConfig = yield (0, config_dev_1.default)(projectConfig);
|
|
132
|
+
const rsbuild = yield (0, core_1.createRsbuild)({ config: startConfig });
|
|
154
133
|
try {
|
|
155
|
-
yield
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
compiler.getInfrastructureLogger = oriLogger;
|
|
159
|
-
handleWatch(projectPath, devServer, env);
|
|
134
|
+
const { server } = yield rsbuild.startDevServer();
|
|
135
|
+
createCompileListener(rsbuild);
|
|
136
|
+
handleWatch(projectPath, server, env);
|
|
160
137
|
if (SWICO_DEV_RESTART !== 'true' ||
|
|
161
138
|
(SWICO_DEV_RESTART === 'true' && newRouterBase !== SWICO_DEV_ROUTER_BASE)) {
|
|
162
|
-
utils_1.toast.info(`Project is running at:${chalk_1.default.hex('#29abe0')(`${
|
|
139
|
+
utils_1.toast.info(`Project is running at:${chalk_1.default.hex('#29abe0')(`${customConfig.dev.https ? 'https' : 'http'}://localhost:${rsbuild.context.devServer.port}${newRouterBase}`)}`);
|
|
163
140
|
}
|
|
164
141
|
currentRouterBase = newRouterBase;
|
|
165
|
-
currentPort = availablePort;
|
|
166
142
|
}
|
|
167
143
|
catch (e) {
|
|
168
144
|
const strErr = e.toString();
|
|
@@ -49,3 +49,4 @@ 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<{}>;
|
|
51
51
|
export declare const initConfig: Omit<GlobalSwicoConfigType, 'template'>;
|
|
52
|
+
export declare const customLogger: import("@rsbuild/core").Logger;
|
package/src/main-config/index.js
CHANGED
|
@@ -45,11 +45,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
45
45
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
46
46
|
};
|
|
47
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
-
exports.initConfig = exports.getFormatDefineVars = exports.updateIndexFileText = exports.handleGlobalStyleFile = exports.handleLoadingFile = exports.getProjectConfig = void 0;
|
|
48
|
+
exports.customLogger = exports.initConfig = exports.getFormatDefineVars = exports.updateIndexFileText = exports.handleGlobalStyleFile = exports.handleLoadingFile = exports.getProjectConfig = void 0;
|
|
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
52
|
const utils_1 = require("../utils");
|
|
53
|
+
const core_1 = require("@rsbuild/core");
|
|
53
54
|
const getFormatRouter = (projectPath, routes, templateType) => {
|
|
54
55
|
const _main = (item) => {
|
|
55
56
|
const { component, name, children, redirect, decorator } = item;
|
|
@@ -293,3 +294,10 @@ exports.initConfig = {
|
|
|
293
294
|
routes: []
|
|
294
295
|
}
|
|
295
296
|
};
|
|
297
|
+
exports.customLogger = (0, core_1.createLogger)();
|
|
298
|
+
exports.customLogger.override({
|
|
299
|
+
info(message) {
|
|
300
|
+
},
|
|
301
|
+
warn(message) {
|
|
302
|
+
}
|
|
303
|
+
});
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.default = default_1;
|
|
16
|
+
const path_1 = __importDefault(require("path"));
|
|
17
|
+
const main_config_1 = require("../main-config");
|
|
18
|
+
const plugin_react_1 = require("@rsbuild/plugin-react");
|
|
19
|
+
function default_1(_a) {
|
|
20
|
+
return __awaiter(this, arguments, void 0, function* ({ projectPath, entryPath, env, customConfig }) {
|
|
21
|
+
var _b, _c, _d, _e, _f;
|
|
22
|
+
const customBaseConfig = customConfig.base;
|
|
23
|
+
const getCustomAliasConfig = () => {
|
|
24
|
+
const { alias } = customBaseConfig || {};
|
|
25
|
+
const custAliasConfig = {};
|
|
26
|
+
if (alias) {
|
|
27
|
+
Object.keys(alias).forEach((key) => {
|
|
28
|
+
custAliasConfig[key] = path_1.default.join(projectPath, `/${alias[key]}`);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
return custAliasConfig;
|
|
32
|
+
};
|
|
33
|
+
const publicPath = (_b = customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.publicPath) !== null && _b !== void 0 ? _b : main_config_1.initConfig.publicPath;
|
|
34
|
+
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;
|
|
35
|
+
const initialDefineVarsConfig = {
|
|
36
|
+
SWICO_ENV: JSON.stringify(env),
|
|
37
|
+
SWICO_ROUTER_BASE: JSON.stringify(routerBase),
|
|
38
|
+
SWICO_PUBLIC_PATH: JSON.stringify(publicPath),
|
|
39
|
+
SWICO_STATIC_PUBLIC_PATH: JSON.stringify(env === 'prod' ? publicPath : '/')
|
|
40
|
+
};
|
|
41
|
+
const customDefineVarsConfig = yield (0, main_config_1.getFormatDefineVars)((_e = customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.define) !== null && _e !== void 0 ? _e : {});
|
|
42
|
+
return {
|
|
43
|
+
source: {
|
|
44
|
+
entry: {
|
|
45
|
+
index: entryPath
|
|
46
|
+
},
|
|
47
|
+
define: Object.assign(Object.assign({}, initialDefineVarsConfig), customDefineVarsConfig)
|
|
48
|
+
},
|
|
49
|
+
logLevel: 'error',
|
|
50
|
+
customLogger: main_config_1.customLogger,
|
|
51
|
+
output: {
|
|
52
|
+
distPath: {
|
|
53
|
+
root: path_1.default.join(projectPath, '/dist'),
|
|
54
|
+
html: './',
|
|
55
|
+
favicon: './',
|
|
56
|
+
js: 'js',
|
|
57
|
+
jsAsync: 'js/async',
|
|
58
|
+
css: 'css',
|
|
59
|
+
cssAsync: 'css/async',
|
|
60
|
+
svg: 'static/svg',
|
|
61
|
+
font: 'static/font',
|
|
62
|
+
wasm: 'static/wasm',
|
|
63
|
+
image: 'static/image',
|
|
64
|
+
media: 'static/media',
|
|
65
|
+
assets: 'static/assets'
|
|
66
|
+
},
|
|
67
|
+
assetPrefix: publicPath,
|
|
68
|
+
cleanDistPath: true,
|
|
69
|
+
cssModules: {
|
|
70
|
+
auto: true,
|
|
71
|
+
exportLocalsConvention: 'camelCase',
|
|
72
|
+
localIdentName: env === 'prod'
|
|
73
|
+
? '[local]-[hash:base64:6]'
|
|
74
|
+
: '[path][name]__[local]-[hash:base64:6]'
|
|
75
|
+
},
|
|
76
|
+
dataUriLimit: {
|
|
77
|
+
svg: 4096,
|
|
78
|
+
font: 4096,
|
|
79
|
+
image: 4096,
|
|
80
|
+
media: 4096,
|
|
81
|
+
assets: 4096
|
|
82
|
+
},
|
|
83
|
+
minify: true,
|
|
84
|
+
emitCss: true,
|
|
85
|
+
externals: customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.externals,
|
|
86
|
+
target: 'web'
|
|
87
|
+
},
|
|
88
|
+
resolve: {
|
|
89
|
+
extensions: ['.ts', '.tsx', '.js', '.jsx', '.json'],
|
|
90
|
+
alias: Object.assign({ '@': path_1.default.join(projectPath, '/src'), 'react-router': path_1.default.dirname(require.resolve('react-router')), 'swico/react': path_1.default.join(projectPath, '/.swico/index'), swico: path_1.default.join(projectPath, '/.swico/index'), qs: path_1.default.dirname(require.resolve('qs')) }, getCustomAliasConfig())
|
|
91
|
+
},
|
|
92
|
+
html: {
|
|
93
|
+
template: path_1.default.join(projectPath, '/src/index.ejs'),
|
|
94
|
+
templateParameters: initialDefineVarsConfig
|
|
95
|
+
},
|
|
96
|
+
plugins: [(0, plugin_react_1.pluginReact)(), ...((_f = customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.plugins) !== null && _f !== void 0 ? _f : main_config_1.initConfig.plugins)]
|
|
97
|
+
};
|
|
98
|
+
});
|
|
99
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.default = default_1;
|
|
16
|
+
const path_1 = __importDefault(require("path"));
|
|
17
|
+
const main_config_1 = require("../main-config");
|
|
18
|
+
const plugin_vue_1 = require("@rsbuild/plugin-vue");
|
|
19
|
+
function default_1(_a) {
|
|
20
|
+
return __awaiter(this, arguments, void 0, function* ({ projectPath, entryPath, env, customConfig }) {
|
|
21
|
+
var _b, _c, _d, _e, _f;
|
|
22
|
+
const customBaseConfig = customConfig.base;
|
|
23
|
+
const getCustomAliasConfig = () => {
|
|
24
|
+
const { alias } = customBaseConfig || {};
|
|
25
|
+
const custAliasConfig = {};
|
|
26
|
+
if (alias) {
|
|
27
|
+
Object.keys(alias).forEach((key) => {
|
|
28
|
+
custAliasConfig[key] = path_1.default.join(projectPath, `/${alias[key]}`);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
return custAliasConfig;
|
|
32
|
+
};
|
|
33
|
+
const publicPath = (_b = customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.publicPath) !== null && _b !== void 0 ? _b : main_config_1.initConfig.publicPath;
|
|
34
|
+
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;
|
|
35
|
+
const initialDefineVarsConfig = {
|
|
36
|
+
SWICO_ENV: JSON.stringify(env),
|
|
37
|
+
SWICO_ROUTER_BASE: JSON.stringify(routerBase),
|
|
38
|
+
SWICO_PUBLIC_PATH: JSON.stringify(publicPath),
|
|
39
|
+
SWICO_STATIC_PUBLIC_PATH: JSON.stringify(env === 'prod' ? publicPath : '/')
|
|
40
|
+
};
|
|
41
|
+
const customDefineVarsConfig = yield (0, main_config_1.getFormatDefineVars)((_e = customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.define) !== null && _e !== void 0 ? _e : {});
|
|
42
|
+
return {
|
|
43
|
+
source: {
|
|
44
|
+
entry: {
|
|
45
|
+
index: entryPath
|
|
46
|
+
},
|
|
47
|
+
define: Object.assign(Object.assign({ __VUE_OPTIONS_API__: true, __VUE_PROD_DEVTOOLS__: false, __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: false }, initialDefineVarsConfig), customDefineVarsConfig)
|
|
48
|
+
},
|
|
49
|
+
logLevel: 'error',
|
|
50
|
+
customLogger: main_config_1.customLogger,
|
|
51
|
+
output: {
|
|
52
|
+
distPath: {
|
|
53
|
+
root: path_1.default.join(projectPath, '/dist'),
|
|
54
|
+
html: './',
|
|
55
|
+
favicon: './',
|
|
56
|
+
js: 'js',
|
|
57
|
+
jsAsync: 'js/async',
|
|
58
|
+
css: 'css',
|
|
59
|
+
cssAsync: 'css/async',
|
|
60
|
+
svg: 'static/svg',
|
|
61
|
+
font: 'static/font',
|
|
62
|
+
wasm: 'static/wasm',
|
|
63
|
+
image: 'static/image',
|
|
64
|
+
media: 'static/media',
|
|
65
|
+
assets: 'static/assets'
|
|
66
|
+
},
|
|
67
|
+
assetPrefix: publicPath,
|
|
68
|
+
cleanDistPath: true,
|
|
69
|
+
cssModules: {
|
|
70
|
+
auto: true,
|
|
71
|
+
exportLocalsConvention: 'camelCase',
|
|
72
|
+
localIdentName: env === 'prod'
|
|
73
|
+
? '[local]-[hash:base64:6]'
|
|
74
|
+
: '[path][name]__[local]-[hash:base64:6]'
|
|
75
|
+
},
|
|
76
|
+
dataUriLimit: {
|
|
77
|
+
svg: 4096,
|
|
78
|
+
font: 4096,
|
|
79
|
+
image: 4096,
|
|
80
|
+
media: 4096,
|
|
81
|
+
assets: 4096
|
|
82
|
+
},
|
|
83
|
+
minify: true,
|
|
84
|
+
emitCss: true,
|
|
85
|
+
externals: customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.externals,
|
|
86
|
+
target: 'web'
|
|
87
|
+
},
|
|
88
|
+
resolve: {
|
|
89
|
+
extensions: ['.ts', '.js', '.vue', '.json'],
|
|
90
|
+
alias: Object.assign({ '@': path_1.default.join(projectPath, '/src'), vue: 'vue/dist/vue.esm-bundler.js', 'vue-router': path_1.default.dirname(require.resolve('vue-router')), 'swico/vue': path_1.default.join(projectPath, '/.swico/index'), swico: path_1.default.join(projectPath, '/.swico/index'), qs: path_1.default.dirname(require.resolve('qs')) }, getCustomAliasConfig())
|
|
91
|
+
},
|
|
92
|
+
html: {
|
|
93
|
+
template: path_1.default.join(projectPath, '/src/index.ejs'),
|
|
94
|
+
templateParameters: initialDefineVarsConfig
|
|
95
|
+
},
|
|
96
|
+
plugins: [(0, plugin_vue_1.pluginVue)(), ...((_f = customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.plugins) !== null && _f !== void 0 ? _f : main_config_1.initConfig.plugins)]
|
|
97
|
+
};
|
|
98
|
+
});
|
|
99
|
+
}
|
|
@@ -48,44 +48,52 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
48
48
|
exports.default = default_1;
|
|
49
49
|
const main_config_1 = require("../main-config");
|
|
50
50
|
const path_1 = __importDefault(require("path"));
|
|
51
|
-
const webpack_merge_1 = require("webpack-merge");
|
|
52
51
|
const eslint_rspack_plugin_1 = __importDefault(require("eslint-rspack-plugin"));
|
|
53
52
|
const ts_checker_rspack_plugin_1 = require("ts-checker-rspack-plugin");
|
|
54
53
|
const utils_1 = require("../utils");
|
|
54
|
+
const core_1 = require("@rsbuild/core");
|
|
55
|
+
const plugin_basic_ssl_1 = require("@rsbuild/plugin-basic-ssl");
|
|
55
56
|
function default_1(options) {
|
|
56
57
|
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
58
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
58
59
|
const { projectPath, customConfig, templateType, entryPath, env } = options;
|
|
59
|
-
const getBaseConfig = (yield Promise.resolve(`${templateType === 'vue' ? './
|
|
60
|
+
const getBaseConfig = (yield Promise.resolve(`${templateType === 'vue' ? './config.base.vue' : './config.base.react'}`).then(s => __importStar(require(s)))).default;
|
|
61
|
+
const publicPath = (_b = (_a = customConfig === null || customConfig === void 0 ? void 0 : customConfig.base) === null || _a === void 0 ? void 0 : _a.publicPath) !== null && _b !== void 0 ? _b : main_config_1.initConfig.publicPath;
|
|
60
62
|
const baseConfig = yield getBaseConfig(Object.assign(Object.assign({}, options), { env: 'dev' }));
|
|
61
|
-
const customDevtool = (
|
|
62
|
-
return (0,
|
|
63
|
+
const customDevtool = (_c = customConfig.dev.devtool) !== null && _c !== void 0 ? _c : customConfig.base.devtool;
|
|
64
|
+
return (0, core_1.mergeRsbuildConfig)(baseConfig, {
|
|
63
65
|
mode: 'development',
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
: (
|
|
68
|
-
devServer: {
|
|
66
|
+
server: {
|
|
67
|
+
base: publicPath,
|
|
68
|
+
compress: true,
|
|
69
|
+
headers: (_e = (_d = customConfig === null || customConfig === void 0 ? void 0 : customConfig.dev) === null || _d === void 0 ? void 0 : _d.responseHeaders) !== null && _e !== void 0 ? _e : main_config_1.initConfig.responseHeaders,
|
|
69
70
|
historyApiFallback: {
|
|
70
71
|
index: `${baseConfig.output.publicPath}index.html`
|
|
71
72
|
},
|
|
73
|
+
proxy: (_g = (_f = customConfig === null || customConfig === void 0 ? void 0 : customConfig.dev) === null || _f === void 0 ? void 0 : _f.proxy) !== null && _g !== void 0 ? _g : main_config_1.initConfig.proxy,
|
|
74
|
+
open: false
|
|
75
|
+
},
|
|
76
|
+
dev: {
|
|
72
77
|
client: {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
78
|
+
overlay: false,
|
|
79
|
+
logLevel: 'error',
|
|
80
|
+
hmr: true,
|
|
81
|
+
lazyCompilation: true,
|
|
82
|
+
progress: false
|
|
76
83
|
},
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
84
|
+
assetPrefix: publicPath
|
|
85
|
+
},
|
|
86
|
+
output: {
|
|
87
|
+
sourceMap: {
|
|
88
|
+
js: templateType === 'vue'
|
|
89
|
+
? (customDevtool !== null && customDevtool !== void 0 ? customDevtool : 'cheap-module-source-map')
|
|
90
|
+
: (customDevtool !== null && customDevtool !== void 0 ? customDevtool : 'eval-cheap-module-source-map'),
|
|
91
|
+
css: false,
|
|
92
|
+
extract: false
|
|
93
|
+
}
|
|
87
94
|
},
|
|
88
95
|
plugins: [
|
|
96
|
+
...(customConfig.dev.https === true ? [(0, plugin_basic_ssl_1.pluginBasicSsl)()] : []),
|
|
89
97
|
new ts_checker_rspack_plugin_1.TsCheckerRspackPlugin({
|
|
90
98
|
logger: {
|
|
91
99
|
log: () => { },
|
|
@@ -110,7 +118,7 @@ function default_1(options) {
|
|
|
110
118
|
emitWarning: false,
|
|
111
119
|
cache: true
|
|
112
120
|
}),
|
|
113
|
-
...((
|
|
121
|
+
...((_j = (_h = customConfig.dev) === null || _h === void 0 ? void 0 : _h.plugins) !== null && _j !== void 0 ? _j : [])
|
|
114
122
|
]
|
|
115
123
|
});
|
|
116
124
|
});
|