swico 3.2.0-beta.1 → 3.2.0-beta.3
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 +1 -1
- package/src/command/build.js +8 -3
- package/src/main-config/index.js +5 -5
package/package.json
CHANGED
package/src/command/build.js
CHANGED
|
@@ -18,6 +18,8 @@ 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
20
|
const core_1 = require("@rsbuild/core");
|
|
21
|
+
const path_1 = __importDefault(require("path"));
|
|
22
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
21
23
|
function default_1() {
|
|
22
24
|
return __awaiter(this, void 0, void 0, function* () {
|
|
23
25
|
process.env.SWICO_ENV = 'prod';
|
|
@@ -34,7 +36,7 @@ function default_1() {
|
|
|
34
36
|
});
|
|
35
37
|
const rsbuild = yield (0, core_1.createRsbuild)({ config: buildConfig });
|
|
36
38
|
let now;
|
|
37
|
-
rsbuild.onAfterBuild(({ stats })
|
|
39
|
+
rsbuild.onAfterBuild((_a) => __awaiter(this, [_a], void 0, function* ({ stats }) {
|
|
38
40
|
if (stats.hasErrors()) {
|
|
39
41
|
const info = stats.toJson({ all: true });
|
|
40
42
|
utils_1.toast.error(info.errors.map((item) => item.stack || item.message));
|
|
@@ -42,8 +44,11 @@ function default_1() {
|
|
|
42
44
|
}
|
|
43
45
|
const duration = Date.now() - now;
|
|
44
46
|
utils_1.toast.success(`Build complete in ${(duration / 1000).toFixed(2)}s`);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
const entryFilePath = path_1.default.resolve(projectPath, './.swico/index.js');
|
|
48
|
+
let replaceEntryText = yield fs_extra_1.default.readFile(entryFilePath, 'utf8');
|
|
49
|
+
replaceEntryText = replaceEntryText.replaceAll('.swico/.prod/history.js', '.swico/.dev/history.js');
|
|
50
|
+
yield fs_extra_1.default.writeFile(entryFilePath, replaceEntryText);
|
|
51
|
+
}));
|
|
47
52
|
utils_1.toast.info('Building...');
|
|
48
53
|
now = Date.now();
|
|
49
54
|
yield rsbuild.build();
|
package/src/main-config/index.js
CHANGED
|
@@ -248,20 +248,20 @@ const initTemplateConfig = (routerConfig, templateType, env) => {
|
|
|
248
248
|
.replaceAll('\\', '/');
|
|
249
249
|
replaceEntryText = replaceEntryText.replaceAll(`require("./template-root/.swico-${templateType}/hooks");`, `require("${formatHooksPath}");`);
|
|
250
250
|
const formatHistoryPath = path_1.default
|
|
251
|
-
.resolve(projectPath, `./.swico/.${env}/history`)
|
|
251
|
+
.resolve(projectPath, `./.swico/.${env}/history.js`)
|
|
252
252
|
.replaceAll('\\', '/');
|
|
253
253
|
replaceEntryText = replaceEntryText.replaceAll('require("./mock-history");', `require("${formatHistoryPath}");`);
|
|
254
254
|
yield fs_extra_1.default.writeFile(targetEntryFilePath, replaceEntryText);
|
|
255
255
|
yield handleAndCopyRouterFile(routerConfig, templateType, env);
|
|
256
|
-
const oriHooksFilePath = path_1.default.resolve(__dirname, `../template-root/.swico-${templateType}
|
|
256
|
+
const oriHooksFilePath = path_1.default.resolve(__dirname, `../template-root/.swico-${templateType}/hooks.js`);
|
|
257
257
|
const targetHooksFilePath = path_1.default.resolve(projectPath, './.swico/hooks.js');
|
|
258
258
|
let replaceHooksText = yield fs_extra_1.default.readFile(oriHooksFilePath, 'utf8');
|
|
259
259
|
replaceHooksText = replaceHooksText.replaceAll('$env', `.${env}`);
|
|
260
260
|
yield fs_extra_1.default.writeFile(targetHooksFilePath, replaceHooksText);
|
|
261
|
-
const oriHistoryFilePath = path_1.default.resolve(__dirname, `../template-root/.swico-${templateType}/$env/history`);
|
|
262
|
-
const targetHistoryFilePath = path_1.default.resolve(projectPath, `./.swico${envPath}history`);
|
|
261
|
+
const oriHistoryFilePath = path_1.default.resolve(__dirname, `../template-root/.swico-${templateType}/$env/history.js`);
|
|
262
|
+
const targetHistoryFilePath = path_1.default.resolve(projectPath, `./.swico${envPath}history.js`);
|
|
263
263
|
yield fs_extra_1.default.copyFile(oriHistoryFilePath, targetHistoryFilePath);
|
|
264
|
-
const oriIndexFilePath = path_1.default.resolve(__dirname, `../template-root/.swico-${templateType}/
|
|
264
|
+
const oriIndexFilePath = path_1.default.resolve(__dirname, `../template-root/.swico-${templateType}/$env/index.js`);
|
|
265
265
|
const targetIndexFilePath = path_1.default.resolve(projectPath, `./.swico${envPath}index.js`);
|
|
266
266
|
let replaceIndexText = yield fs_extra_1.default.readFile(oriIndexFilePath, 'utf8');
|
|
267
267
|
replaceIndexText = (0, exports.handleGlobalStyleFile)(replaceIndexText);
|