swico 2.0.0-beta.4 → 2.0.0-beta.40
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 +4 -4
- package/package.json +31 -33
- package/src/bin.js +17 -7
- package/src/command/build.js +3 -2
- package/src/command/start.js +5 -5
- package/src/config/rsbpack.dev.js +24 -13
- package/src/config/rspack.base.react.d.ts +26 -1
- package/src/config/rspack.base.react.js +18 -18
- package/src/config/rspack.base.vue.d.ts +41 -30
- package/src/config/rspack.base.vue.js +45 -44
- package/src/config/rspack.prod.js +39 -34
- package/src/index.d.ts +1 -0
- package/src/index.js +3 -1
- package/src/index.react.d.ts +3 -3
- package/src/index.react.js +7 -5
- package/src/index.vue.d.ts +7 -4
- package/src/index.vue.js +3 -1
- package/src/project-path/.swico-react/$env/history.js +1 -1
- package/src/project-path/.swico-react/$env/index.js +21 -11
- package/src/project-path/.swico-react/react-hooks.js +4 -4
- package/src/project-path/.swico-vue/Container.d.ts +1 -1
- package/src/project-path/src/layout/Layout.d.ts +1 -1
- package/src/project-path/src/layout/index.js +2 -2
- package/src/utils/config.d.ts +1 -1
- package/src/utils/config.js +17 -7
- package/src/utils/tools.d.ts +1 -1
- package/src/utils/tools.js +21 -13
package/README.md
CHANGED
|
@@ -7,15 +7,15 @@ Swico,发音近似于“斯威扣”。
|
|
|
7
7
|
|
|
8
8
|
## 主要特性
|
|
9
9
|
|
|
10
|
-
- 构建工具基于
|
|
10
|
+
- 构建工具基于Rspack 1.x,基于Rust多线程驱动,显著提升编译性能。
|
|
11
11
|
|
|
12
12
|
- 提供Vue3和React18两种开发模板选择,默认集成TypeScript5。同时最大化统一这两种模板的开发API。
|
|
13
13
|
|
|
14
|
-
- 提供可配置化路由方案,基于React-
|
|
14
|
+
- 提供可配置化路由方案,基于React-Router7和Vue-Router4进行二次封装,支持路由嵌套,懒加载,动态参数,装饰校验等功能。
|
|
15
15
|
|
|
16
|
-
-
|
|
16
|
+
- 内置支持ESLint / Prettier / Husky等编码风格以及代码提交规范约束功能配置,保证代码风格统一以及 Git 提交规范。
|
|
17
17
|
|
|
18
|
-
-
|
|
18
|
+
- 提供配置文件可按需对架构配置进行修改扩展,例如Alias映射,本地请求代理等。
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
官方文档:[SWICO 官方文档](https://scw1997.github.io/swico-docs)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "swico",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.40",
|
|
4
4
|
"description": "Simple, efficient, and practical front-end framework",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"types": "./src/index.d.ts",
|
|
@@ -10,10 +10,8 @@
|
|
|
10
10
|
"ecmascript",
|
|
11
11
|
"react",
|
|
12
12
|
"vue",
|
|
13
|
-
"cli",
|
|
14
13
|
"swico",
|
|
15
|
-
"
|
|
16
|
-
"webpack"
|
|
14
|
+
"rspack"
|
|
17
15
|
],
|
|
18
16
|
"bin": {
|
|
19
17
|
"swico": "./src/bin.js"
|
|
@@ -21,7 +19,8 @@
|
|
|
21
19
|
"scripts": {
|
|
22
20
|
"compile": "tsc && ts-node ./src/task.ts",
|
|
23
21
|
"publish:offical": "npm run compile && cd ./dist && npm publish",
|
|
24
|
-
"publish:beta": "npm run compile && cd ./dist && npm publish --tag=beta"
|
|
22
|
+
"publish:beta": "npm run compile && cd ./dist && npm publish --tag=beta",
|
|
23
|
+
"lint:fix": "eslint --fix src/**/*.{js,jsx,ts,tsx} "
|
|
25
24
|
},
|
|
26
25
|
"repository": {
|
|
27
26
|
"type": "git",
|
|
@@ -30,53 +29,52 @@
|
|
|
30
29
|
"author": "scw",
|
|
31
30
|
"license": "ISC",
|
|
32
31
|
"dependencies": {
|
|
33
|
-
"@
|
|
34
|
-
"@rspack/
|
|
35
|
-
"@
|
|
36
|
-
"@swc/core": "1.4.6",
|
|
37
|
-
"@vue/compiler-sfc": "3.4.14",
|
|
32
|
+
"@rspack/core": "1.3.5",
|
|
33
|
+
"@rspack/dev-server": "1.1.1",
|
|
34
|
+
"@vue/compiler-sfc": "3.5.13",
|
|
38
35
|
"autoprefixer": "10.3.7",
|
|
39
36
|
"chalk": "4.1.2",
|
|
40
37
|
"chokidar": "3.6.0",
|
|
41
38
|
"commander": "12.0.0",
|
|
42
39
|
"cross-spawn": "7.0.5",
|
|
43
|
-
"css-loader": "
|
|
44
|
-
"eslint-plugin
|
|
45
|
-
"eslint-plugin-react-hooks": "4.3.0",
|
|
46
|
-
"eslint-plugin-vue": "9.19.2",
|
|
47
|
-
"eslint-webpack-plugin": "4.0.0",
|
|
40
|
+
"css-loader": "7.1.2",
|
|
41
|
+
"eslint-rspack-plugin": "4.2.1",
|
|
48
42
|
"fs-extra": "11.3.0",
|
|
49
|
-
"html-loader": "5.
|
|
50
|
-
"less": "4.
|
|
43
|
+
"html-loader": "5.1.0",
|
|
44
|
+
"less": "4.3.0",
|
|
51
45
|
"less-loader": "12.2.0",
|
|
52
46
|
"ora": "5.4.1",
|
|
53
47
|
"portfinder": "1.0.32",
|
|
54
48
|
"postcss-loader": "8.1.0",
|
|
55
49
|
"postcss-preset-env": "9.3.0",
|
|
56
50
|
"qs": "6.13.0",
|
|
57
|
-
"react-router
|
|
58
|
-
"sass": "1.
|
|
59
|
-
"sass-loader": "
|
|
51
|
+
"react-router": "7.5.0",
|
|
52
|
+
"sass-embedded": "1.86.3",
|
|
53
|
+
"sass-loader": "16.0.5",
|
|
60
54
|
"style-loader": "3.3.0",
|
|
61
|
-
"ts-checker-rspack-plugin": "
|
|
55
|
+
"ts-checker-rspack-plugin": "1.1.1",
|
|
62
56
|
"ts-node": "10.9.1",
|
|
63
57
|
"vue-loader": "17.4.2",
|
|
64
|
-
"vue-router": "
|
|
58
|
+
"vue-router": "4.5.0",
|
|
65
59
|
"vue-style-loader": "4.1.3",
|
|
66
60
|
"webpack-bundle-analyzer": "4.9.1",
|
|
67
|
-
"webpack-merge": "
|
|
68
|
-
"webpackbar": "^7.0.0"
|
|
61
|
+
"webpack-merge": "6.0.1"
|
|
69
62
|
},
|
|
70
63
|
"devDependencies": {
|
|
64
|
+
"@eslint/js": "9.24.0",
|
|
71
65
|
"@types/node": "22.13.10",
|
|
72
|
-
"@types/react": "
|
|
73
|
-
"@types/react-dom": "
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"react": "~
|
|
78
|
-
"react-dom": "~
|
|
79
|
-
"typescript": "5.
|
|
80
|
-
"
|
|
66
|
+
"@types/react": "19.1.0",
|
|
67
|
+
"@types/react-dom": "19.1.0",
|
|
68
|
+
"eslint": "9.24.0",
|
|
69
|
+
"globals": "16.0.0",
|
|
70
|
+
"prettier": "3.5.3",
|
|
71
|
+
"react": "~19.1.0",
|
|
72
|
+
"react-dom": "~19.1.0",
|
|
73
|
+
"typescript": "5.8.3",
|
|
74
|
+
"typescript-eslint": "8.30.1",
|
|
75
|
+
"vue": "~3.5.13"
|
|
76
|
+
},
|
|
77
|
+
"engines": {
|
|
78
|
+
"node": ">=20.0.0"
|
|
81
79
|
}
|
|
82
80
|
}
|
package/src/bin.js
CHANGED
|
@@ -16,13 +16,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
16
16
|
}) : function(o, v) {
|
|
17
17
|
o["default"] = v;
|
|
18
18
|
});
|
|
19
|
-
var __importStar = (this && this.__importStar) || function (
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
};
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
26
36
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
27
37
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
28
38
|
};
|
package/src/command/build.js
CHANGED
|
@@ -12,6 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.default = default_1;
|
|
15
16
|
const rspack_prod_1 = __importDefault(require("../config/rspack.prod"));
|
|
16
17
|
const config_1 = require("../utils/config");
|
|
17
18
|
const tools_1 = require("../utils/tools");
|
|
@@ -33,6 +34,7 @@ function default_1() {
|
|
|
33
34
|
templateType
|
|
34
35
|
});
|
|
35
36
|
const compiler = (0, core_1.rspack)(buildConfig);
|
|
37
|
+
tools_1.toast.info('Building...');
|
|
36
38
|
compiler.run((err, stats) => {
|
|
37
39
|
if (err) {
|
|
38
40
|
tools_1.toast.error(err.stack || err.toString());
|
|
@@ -46,8 +48,7 @@ function default_1() {
|
|
|
46
48
|
if (stats.hasWarnings()) {
|
|
47
49
|
tools_1.toast.warning(info.warnings.map((item) => item.stack || item.message));
|
|
48
50
|
}
|
|
49
|
-
tools_1.toast.success(
|
|
51
|
+
tools_1.toast.success(`Build complete ${(info === null || info === void 0 ? void 0 : info.time) ? `in ${(info.time / 1000).toFixed(2)}s` : ''}`);
|
|
50
52
|
});
|
|
51
53
|
});
|
|
52
54
|
}
|
|
53
|
-
exports.default = default_1;
|
package/src/command/start.js
CHANGED
|
@@ -12,6 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.default = start;
|
|
15
16
|
const rsbpack_dev_1 = __importDefault(require("../config/rsbpack.dev"));
|
|
16
17
|
const tools_1 = require("../utils/tools");
|
|
17
18
|
const config_1 = require("../utils/config");
|
|
@@ -28,14 +29,14 @@ let currentPort, currentRouterBase = '/';
|
|
|
28
29
|
const handleWatch = (projectPath, devServer, env) => {
|
|
29
30
|
const envPath = env === 'dev' ? '/.dev/' : '/.prod/';
|
|
30
31
|
const configFilesWatcher = chokidar_1.default
|
|
31
|
-
.watch([path_1.default.join(projectPath, '/config/*.ts'), path_1.default.join(projectPath, '/.
|
|
32
|
+
.watch([path_1.default.join(projectPath, '/config/*.ts'), path_1.default.join(projectPath, '/.eslint.config.mjs')], {
|
|
32
33
|
interval: 500,
|
|
33
34
|
binaryInterval: 500,
|
|
34
35
|
ignoreInitial: true,
|
|
35
36
|
ignored: [path_1.default.join(projectPath, '/config/swico.prod.ts')]
|
|
36
37
|
})
|
|
37
38
|
.on('all', (path, stats) => __awaiter(void 0, void 0, void 0, function* () {
|
|
38
|
-
tools_1.toast.warning('
|
|
39
|
+
tools_1.toast.warning('Configuration files changed, restarting server...', {
|
|
39
40
|
inline: true
|
|
40
41
|
});
|
|
41
42
|
yield devServer.stop();
|
|
@@ -119,7 +120,7 @@ const createCompileListener = (compiler) => {
|
|
|
119
120
|
const warnings = info.warnings;
|
|
120
121
|
warnings.some((item) => {
|
|
121
122
|
const msg = item.message || item.stack;
|
|
122
|
-
if (msg.
|
|
123
|
+
if (msg.includes('[eslint]')) {
|
|
123
124
|
tools_1.toast.warning(msg, { title: 'ESLint errors' });
|
|
124
125
|
return;
|
|
125
126
|
}
|
|
@@ -129,8 +130,8 @@ const createCompileListener = (compiler) => {
|
|
|
129
130
|
});
|
|
130
131
|
};
|
|
131
132
|
function start() {
|
|
132
|
-
var _a, _b, _c, _d, _e, _f;
|
|
133
133
|
return __awaiter(this, void 0, void 0, function* () {
|
|
134
|
+
var _a, _b, _c, _d, _e, _f;
|
|
134
135
|
process.env.SWICO_ENV = 'dev';
|
|
135
136
|
if (SWICO_RESTART !== 'true') {
|
|
136
137
|
console.log('\n');
|
|
@@ -168,4 +169,3 @@ function start() {
|
|
|
168
169
|
}
|
|
169
170
|
});
|
|
170
171
|
}
|
|
171
|
-
exports.default = start;
|
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
36
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
37
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -35,15 +45,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
35
45
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
46
|
};
|
|
37
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
+
exports.default = default_1;
|
|
38
49
|
const config_1 = require("../utils/config");
|
|
39
50
|
const path_1 = __importDefault(require("path"));
|
|
40
51
|
const webpack_merge_1 = require("webpack-merge");
|
|
41
|
-
const
|
|
52
|
+
const eslint_rspack_plugin_1 = __importDefault(require("eslint-rspack-plugin"));
|
|
42
53
|
const ts_checker_rspack_plugin_1 = require("ts-checker-rspack-plugin");
|
|
43
54
|
const tools_1 = require("../utils/tools");
|
|
44
55
|
function default_1(options) {
|
|
45
|
-
var _a, _b, _c, _d, _e;
|
|
46
56
|
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
var _a, _b, _c, _d, _e;
|
|
47
58
|
const { projectPath, customConfig, templateType, entryPath, env } = options;
|
|
48
59
|
const getBaseConfig = (yield Promise.resolve(`${templateType === 'vue' ? './rspack.base.vue' : './rspack.base.react'}`).then(s => __importStar(require(s)))).default;
|
|
49
60
|
const baseConfig = yield getBaseConfig(Object.assign(Object.assign({}, options), { env: 'dev' }));
|
|
@@ -52,8 +63,8 @@ function default_1(options) {
|
|
|
52
63
|
mode: 'development',
|
|
53
64
|
stats: 'none',
|
|
54
65
|
devtool: templateType === 'vue'
|
|
55
|
-
? customDevtool !== null && customDevtool !== void 0 ? customDevtool : 'cheap-module-source-map'
|
|
56
|
-
: customDevtool !== null && customDevtool !== void 0 ? customDevtool : 'eval-cheap-module-source-map',
|
|
66
|
+
? (customDevtool !== null && customDevtool !== void 0 ? customDevtool : 'cheap-module-source-map')
|
|
67
|
+
: (customDevtool !== null && customDevtool !== void 0 ? customDevtool : 'eval-cheap-module-source-map'),
|
|
57
68
|
devServer: {
|
|
58
69
|
historyApiFallback: {
|
|
59
70
|
index: `${baseConfig.output.publicPath}index.html`
|
|
@@ -88,7 +99,8 @@ function default_1(options) {
|
|
|
88
99
|
}
|
|
89
100
|
}
|
|
90
101
|
}),
|
|
91
|
-
new
|
|
102
|
+
new eslint_rspack_plugin_1.default({
|
|
103
|
+
configType: 'flat',
|
|
92
104
|
context: path_1.default.join(projectPath, '/src'),
|
|
93
105
|
failOnError: false,
|
|
94
106
|
failOnWarning: true,
|
|
@@ -101,4 +113,3 @@ function default_1(options) {
|
|
|
101
113
|
});
|
|
102
114
|
});
|
|
103
115
|
}
|
|
104
|
-
exports.default = default_1;
|
|
@@ -4,6 +4,9 @@ export default function ({ projectPath, entryPath, env, customConfig }: GlobalDa
|
|
|
4
4
|
output: {
|
|
5
5
|
path: string;
|
|
6
6
|
filename: string;
|
|
7
|
+
chunkFilename: string;
|
|
8
|
+
cssFilename: string;
|
|
9
|
+
cssChunkFilename: string;
|
|
7
10
|
assetModuleFilename: string;
|
|
8
11
|
publicPath: string;
|
|
9
12
|
clean: boolean;
|
|
@@ -57,6 +60,28 @@ export default function ({ projectPath, entryPath, env, customConfig }: GlobalDa
|
|
|
57
60
|
})[];
|
|
58
61
|
generator?: undefined;
|
|
59
62
|
loader?: undefined;
|
|
63
|
+
} | {
|
|
64
|
+
test: RegExp;
|
|
65
|
+
type: string;
|
|
66
|
+
use: ({
|
|
67
|
+
loader: string;
|
|
68
|
+
options: {
|
|
69
|
+
postcssOptions: {
|
|
70
|
+
plugins: string[][];
|
|
71
|
+
};
|
|
72
|
+
api?: undefined;
|
|
73
|
+
implementation?: undefined;
|
|
74
|
+
};
|
|
75
|
+
} | {
|
|
76
|
+
loader: string;
|
|
77
|
+
options: {
|
|
78
|
+
api: string;
|
|
79
|
+
implementation: string;
|
|
80
|
+
postcssOptions?: undefined;
|
|
81
|
+
};
|
|
82
|
+
})[];
|
|
83
|
+
generator?: undefined;
|
|
84
|
+
loader?: undefined;
|
|
60
85
|
} | {
|
|
61
86
|
test: RegExp;
|
|
62
87
|
type: string;
|
|
@@ -87,7 +112,7 @@ export default function ({ projectPath, entryPath, env, customConfig }: GlobalDa
|
|
|
87
112
|
extensions: string[];
|
|
88
113
|
alias: {
|
|
89
114
|
'@': string;
|
|
90
|
-
'react-router
|
|
115
|
+
'react-router': string;
|
|
91
116
|
qs: string;
|
|
92
117
|
};
|
|
93
118
|
};
|
|
@@ -12,6 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.default = default_1;
|
|
15
16
|
const path_1 = __importDefault(require("path"));
|
|
16
17
|
const config_1 = require("../utils/config");
|
|
17
18
|
const core_1 = require("@rspack/core");
|
|
@@ -19,9 +20,9 @@ const cssLoader = require.resolve('css-loader');
|
|
|
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
|
-
function default_1(
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
function default_1(_a) {
|
|
24
|
+
return __awaiter(this, arguments, void 0, function* ({ projectPath, entryPath, env, customConfig }) {
|
|
25
|
+
var _b, _c, _d;
|
|
25
26
|
const customBaseConfig = customConfig.base;
|
|
26
27
|
const getCustomAliasConfig = () => {
|
|
27
28
|
const { alias } = customBaseConfig || {};
|
|
@@ -34,9 +35,9 @@ function default_1({ projectPath, entryPath, env, customConfig }) {
|
|
|
34
35
|
return custAliasConfig;
|
|
35
36
|
};
|
|
36
37
|
const publicPath = (customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.publicPath) || config_1.initConfig.publicPath;
|
|
37
|
-
const routerBase = ((
|
|
38
|
+
const routerBase = ((_b = customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.router) === null || _b === void 0 ? void 0 : _b.base) || config_1.initConfig.router.base;
|
|
38
39
|
const basicPlugins = [];
|
|
39
|
-
const defineConfigData = (
|
|
40
|
+
const defineConfigData = (_d = (_c = customConfig === null || customConfig === void 0 ? void 0 : customConfig.base) === null || _c === void 0 ? void 0 : _c.define) !== null && _d !== void 0 ? _d : {};
|
|
40
41
|
const formatObj = yield (0, config_1.getFormatDefineVars)(defineConfigData);
|
|
41
42
|
if (Object.keys(formatObj).length !== 0) {
|
|
42
43
|
basicPlugins.push(new core_1.rspack.DefinePlugin(formatObj));
|
|
@@ -46,6 +47,9 @@ function default_1({ projectPath, entryPath, env, customConfig }) {
|
|
|
46
47
|
output: {
|
|
47
48
|
path: path_1.default.join(projectPath, '/dist'),
|
|
48
49
|
filename: 'js/[name].[chunkhash].js',
|
|
50
|
+
chunkFilename: 'js/[name].[chunkhash].js',
|
|
51
|
+
cssFilename: 'css/[id].css',
|
|
52
|
+
cssChunkFilename: 'css/[id].css',
|
|
49
53
|
assetModuleFilename: 'assets/[name]_[chunkhash][ext]',
|
|
50
54
|
publicPath,
|
|
51
55
|
clean: true
|
|
@@ -53,7 +57,7 @@ function default_1({ projectPath, entryPath, env, customConfig }) {
|
|
|
53
57
|
experiments: {
|
|
54
58
|
css: true
|
|
55
59
|
},
|
|
56
|
-
target: ['web', '
|
|
60
|
+
target: ['web', 'es2015'],
|
|
57
61
|
module: {
|
|
58
62
|
parser: {
|
|
59
63
|
'css/auto': {
|
|
@@ -94,7 +98,6 @@ function default_1({ projectPath, entryPath, env, customConfig }) {
|
|
|
94
98
|
test: /\.css$/,
|
|
95
99
|
type: 'css/auto',
|
|
96
100
|
use: [
|
|
97
|
-
core_1.rspack.CssExtractRspackPlugin.loader,
|
|
98
101
|
cssLoader,
|
|
99
102
|
{
|
|
100
103
|
loader: postcssLoader,
|
|
@@ -110,8 +113,6 @@ function default_1({ projectPath, entryPath, env, customConfig }) {
|
|
|
110
113
|
test: /\.less$/,
|
|
111
114
|
type: 'css/auto',
|
|
112
115
|
use: [
|
|
113
|
-
core_1.rspack.CssExtractRspackPlugin.loader,
|
|
114
|
-
cssLoader,
|
|
115
116
|
{
|
|
116
117
|
loader: postcssLoader,
|
|
117
118
|
options: {
|
|
@@ -127,8 +128,6 @@ function default_1({ projectPath, entryPath, env, customConfig }) {
|
|
|
127
128
|
test: /\.scss$/,
|
|
128
129
|
type: 'css/auto',
|
|
129
130
|
use: [
|
|
130
|
-
core_1.rspack.CssExtractRspackPlugin.loader,
|
|
131
|
-
cssLoader,
|
|
132
131
|
{
|
|
133
132
|
loader: postcssLoader,
|
|
134
133
|
options: {
|
|
@@ -137,7 +136,13 @@ function default_1({ projectPath, entryPath, env, customConfig }) {
|
|
|
137
136
|
}
|
|
138
137
|
}
|
|
139
138
|
},
|
|
140
|
-
|
|
139
|
+
{
|
|
140
|
+
loader: sassLoader,
|
|
141
|
+
options: {
|
|
142
|
+
api: 'modern-compiler',
|
|
143
|
+
implementation: require.resolve('sass-embedded')
|
|
144
|
+
}
|
|
145
|
+
}
|
|
141
146
|
]
|
|
142
147
|
},
|
|
143
148
|
{
|
|
@@ -168,7 +173,7 @@ function default_1({ projectPath, entryPath, env, customConfig }) {
|
|
|
168
173
|
},
|
|
169
174
|
resolve: {
|
|
170
175
|
extensions: ['.ts', '.tsx', '.js', '.jsx', '.json'],
|
|
171
|
-
alias: Object.assign({ '@': path_1.default.join(projectPath, '/src'), 'react-router
|
|
176
|
+
alias: Object.assign({ '@': path_1.default.join(projectPath, '/src'), 'react-router': path_1.default.dirname(require.resolve('react-router')), qs: path_1.default.dirname(require.resolve('qs')) }, getCustomAliasConfig())
|
|
172
177
|
},
|
|
173
178
|
externals: customConfig.base.externals,
|
|
174
179
|
plugins: [
|
|
@@ -183,13 +188,8 @@ function default_1({ projectPath, entryPath, env, customConfig }) {
|
|
|
183
188
|
},
|
|
184
189
|
hash: true
|
|
185
190
|
}),
|
|
186
|
-
new core_1.rspack.CssExtractRspackPlugin({
|
|
187
|
-
filename: env === 'dev' ? 'css/[name].css' : 'css/[name].[contenthash].css',
|
|
188
|
-
ignoreOrder: true
|
|
189
|
-
}),
|
|
190
191
|
...((customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.plugins) || config_1.initConfig.plugins)
|
|
191
192
|
]
|
|
192
193
|
};
|
|
193
194
|
});
|
|
194
195
|
}
|
|
195
|
-
exports.default = default_1;
|
|
@@ -4,17 +4,15 @@ export default function ({ projectPath, entryPath, env, customConfig }: GlobalDa
|
|
|
4
4
|
output: {
|
|
5
5
|
path: string;
|
|
6
6
|
filename: string;
|
|
7
|
+
chunkFilename: string;
|
|
8
|
+
cssFilename: string;
|
|
9
|
+
cssChunkFilename: string;
|
|
7
10
|
assetModuleFilename: string;
|
|
8
11
|
publicPath: string;
|
|
9
12
|
clean: boolean;
|
|
10
13
|
};
|
|
11
14
|
target: string[];
|
|
12
15
|
module: {
|
|
13
|
-
parser: {
|
|
14
|
-
'css/auto': {
|
|
15
|
-
namedExports: boolean;
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
16
|
rules: ({
|
|
19
17
|
test: RegExp;
|
|
20
18
|
loader: string;
|
|
@@ -24,6 +22,8 @@ export default function ({ projectPath, entryPath, env, customConfig }: GlobalDa
|
|
|
24
22
|
};
|
|
25
23
|
use?: undefined;
|
|
26
24
|
oneOf?: undefined;
|
|
25
|
+
type?: undefined;
|
|
26
|
+
generator?: undefined;
|
|
27
27
|
} | {
|
|
28
28
|
test: RegExp;
|
|
29
29
|
exclude: RegExp;
|
|
@@ -44,8 +44,10 @@ export default function ({ projectPath, entryPath, env, customConfig }: GlobalDa
|
|
|
44
44
|
loader?: undefined;
|
|
45
45
|
options?: undefined;
|
|
46
46
|
oneOf?: undefined;
|
|
47
|
+
type?: undefined;
|
|
48
|
+
generator?: undefined;
|
|
47
49
|
} | {
|
|
48
|
-
oneOf:
|
|
50
|
+
oneOf: {
|
|
49
51
|
test: RegExp;
|
|
50
52
|
oneOf: ({
|
|
51
53
|
resourceQuery: RegExp;
|
|
@@ -54,6 +56,7 @@ export default function ({ projectPath, entryPath, env, customConfig }: GlobalDa
|
|
|
54
56
|
options: {
|
|
55
57
|
modules: {
|
|
56
58
|
localIdentName: string;
|
|
59
|
+
namedExport: boolean;
|
|
57
60
|
};
|
|
58
61
|
postcssOptions?: undefined;
|
|
59
62
|
};
|
|
@@ -77,35 +80,43 @@ export default function ({ projectPath, entryPath, env, customConfig }: GlobalDa
|
|
|
77
80
|
})[];
|
|
78
81
|
resourceQuery?: undefined;
|
|
79
82
|
})[];
|
|
80
|
-
|
|
81
|
-
generator?: undefined;
|
|
82
|
-
loader?: undefined;
|
|
83
|
-
} | {
|
|
84
|
-
test: RegExp;
|
|
85
|
-
type: string;
|
|
86
|
-
generator: {
|
|
87
|
-
filename: string;
|
|
88
|
-
};
|
|
89
|
-
oneOf?: undefined;
|
|
90
|
-
loader?: undefined;
|
|
91
|
-
} | {
|
|
92
|
-
test: RegExp;
|
|
93
|
-
type: string;
|
|
94
|
-
oneOf?: undefined;
|
|
95
|
-
generator?: undefined;
|
|
96
|
-
loader?: undefined;
|
|
97
|
-
} | {
|
|
98
|
-
test: RegExp;
|
|
99
|
-
loader: string;
|
|
100
|
-
oneOf?: undefined;
|
|
101
|
-
type?: undefined;
|
|
102
|
-
generator?: undefined;
|
|
103
|
-
})[];
|
|
83
|
+
}[];
|
|
104
84
|
test?: undefined;
|
|
105
85
|
loader?: undefined;
|
|
106
86
|
exclude?: undefined;
|
|
107
87
|
options?: undefined;
|
|
108
88
|
use?: undefined;
|
|
89
|
+
type?: undefined;
|
|
90
|
+
generator?: undefined;
|
|
91
|
+
} | {
|
|
92
|
+
test: RegExp;
|
|
93
|
+
type: string;
|
|
94
|
+
generator: {
|
|
95
|
+
filename: string;
|
|
96
|
+
};
|
|
97
|
+
loader?: undefined;
|
|
98
|
+
exclude?: undefined;
|
|
99
|
+
options?: undefined;
|
|
100
|
+
use?: undefined;
|
|
101
|
+
oneOf?: undefined;
|
|
102
|
+
} | {
|
|
103
|
+
test: RegExp;
|
|
104
|
+
type: string;
|
|
105
|
+
loader?: undefined;
|
|
106
|
+
exclude?: undefined;
|
|
107
|
+
options?: undefined;
|
|
108
|
+
use?: undefined;
|
|
109
|
+
oneOf?: undefined;
|
|
110
|
+
generator?: undefined;
|
|
111
|
+
} | {
|
|
112
|
+
test: RegExp;
|
|
113
|
+
loader: string;
|
|
114
|
+
exclude?: undefined;
|
|
115
|
+
options?: undefined;
|
|
116
|
+
use?: undefined;
|
|
117
|
+
oneOf?: undefined;
|
|
118
|
+
type?: undefined;
|
|
119
|
+
generator?: undefined;
|
|
109
120
|
})[];
|
|
110
121
|
};
|
|
111
122
|
resolve: {
|
|
@@ -12,6 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.default = default_1;
|
|
15
16
|
const path_1 = __importDefault(require("path"));
|
|
16
17
|
const config_1 = require("../utils/config");
|
|
17
18
|
const vue_loader_1 = require("vue-loader");
|
|
@@ -21,9 +22,9 @@ const cssLoader = require.resolve('css-loader');
|
|
|
21
22
|
const lessLoader = require.resolve('less-loader');
|
|
22
23
|
const sassLoader = require.resolve('sass-loader');
|
|
23
24
|
const postcssLoader = require.resolve('postcss-loader');
|
|
24
|
-
function default_1(
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
function default_1(_a) {
|
|
26
|
+
return __awaiter(this, arguments, void 0, function* ({ projectPath, entryPath, env, customConfig }) {
|
|
27
|
+
var _b, _c, _d;
|
|
27
28
|
const customBaseConfig = customConfig.base;
|
|
28
29
|
const getCustomAliasConfig = () => {
|
|
29
30
|
const { alias } = customBaseConfig || {};
|
|
@@ -36,29 +37,27 @@ function default_1({ projectPath, entryPath, env, customConfig }) {
|
|
|
36
37
|
return custAliasConfig;
|
|
37
38
|
};
|
|
38
39
|
const publicPath = (customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.publicPath) || config_1.initConfig.publicPath;
|
|
39
|
-
const routerBase = ((
|
|
40
|
+
const routerBase = ((_b = customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.router) === null || _b === void 0 ? void 0 : _b.base) || config_1.initConfig.router.base;
|
|
40
41
|
const basicPlugins = [];
|
|
41
|
-
const defineConfigData = (
|
|
42
|
+
const defineConfigData = (_d = (_c = customConfig === null || customConfig === void 0 ? void 0 : customConfig.base) === null || _c === void 0 ? void 0 : _c.define) !== null && _d !== void 0 ? _d : {};
|
|
42
43
|
const formatObj = yield (0, config_1.getFormatDefineVars)(defineConfigData);
|
|
43
44
|
if (Object.keys(formatObj).length !== 0) {
|
|
44
|
-
basicPlugins.push(new core_1.
|
|
45
|
+
basicPlugins.push(new core_1.DefinePlugin(formatObj));
|
|
45
46
|
}
|
|
46
47
|
return {
|
|
47
48
|
entry: entryPath,
|
|
48
49
|
output: {
|
|
49
50
|
path: path_1.default.join(projectPath, '/dist'),
|
|
50
51
|
filename: 'js/[name].[chunkhash].js',
|
|
51
|
-
|
|
52
|
+
chunkFilename: 'js/[name].[chunkhash].js',
|
|
53
|
+
cssFilename: 'css/[id].css',
|
|
54
|
+
cssChunkFilename: 'css/[id].css',
|
|
55
|
+
assetModuleFilename: 'assets/[name]_[id][ext]',
|
|
52
56
|
publicPath,
|
|
53
57
|
clean: true
|
|
54
58
|
},
|
|
55
59
|
target: ['web', 'es5'],
|
|
56
60
|
module: {
|
|
57
|
-
parser: {
|
|
58
|
-
'css/auto': {
|
|
59
|
-
namedExports: false
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
61
|
rules: [
|
|
63
62
|
{
|
|
64
63
|
test: /\.vue$/,
|
|
@@ -101,7 +100,8 @@ function default_1({ projectPath, entryPath, env, customConfig }) {
|
|
|
101
100
|
loader: cssLoader,
|
|
102
101
|
options: {
|
|
103
102
|
modules: {
|
|
104
|
-
localIdentName: 'moduleStyle_[local]_[contenthash:8]'
|
|
103
|
+
localIdentName: 'moduleStyle_[local]_[contenthash:8]',
|
|
104
|
+
namedExport: false
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
},
|
|
@@ -144,7 +144,8 @@ function default_1({ projectPath, entryPath, env, customConfig }) {
|
|
|
144
144
|
loader: cssLoader,
|
|
145
145
|
options: {
|
|
146
146
|
modules: {
|
|
147
|
-
localIdentName: 'moduleStyle_[local]_[contenthash:8]'
|
|
147
|
+
localIdentName: 'moduleStyle_[local]_[contenthash:8]',
|
|
148
|
+
namedExport: false
|
|
148
149
|
}
|
|
149
150
|
}
|
|
150
151
|
},
|
|
@@ -189,7 +190,8 @@ function default_1({ projectPath, entryPath, env, customConfig }) {
|
|
|
189
190
|
loader: cssLoader,
|
|
190
191
|
options: {
|
|
191
192
|
modules: {
|
|
192
|
-
localIdentName: 'moduleStyle_[local]_[contenthash:8]'
|
|
193
|
+
localIdentName: 'moduleStyle_[local]_[contenthash:8]',
|
|
194
|
+
namedExport: false
|
|
193
195
|
}
|
|
194
196
|
}
|
|
195
197
|
},
|
|
@@ -222,30 +224,30 @@ function default_1({ projectPath, entryPath, env, customConfig }) {
|
|
|
222
224
|
]
|
|
223
225
|
}
|
|
224
226
|
]
|
|
225
|
-
},
|
|
226
|
-
{
|
|
227
|
-
test: /\.(jpg|png|gif|webp|bmp|jpeg|svg)$/,
|
|
228
|
-
type: 'asset',
|
|
229
|
-
generator: {
|
|
230
|
-
filename: 'images/[name]_[contenthash][ext]'
|
|
231
|
-
}
|
|
232
|
-
},
|
|
233
|
-
{
|
|
234
|
-
test: /\.(otf|eot|woff2?|ttf)$/i,
|
|
235
|
-
type: 'asset',
|
|
236
|
-
generator: {
|
|
237
|
-
filename: 'fonts/[name]_[contenthash][ext]'
|
|
238
|
-
}
|
|
239
|
-
},
|
|
240
|
-
{
|
|
241
|
-
test: /\.(txt|xml)$/i,
|
|
242
|
-
type: 'asset/source'
|
|
243
|
-
},
|
|
244
|
-
{
|
|
245
|
-
test: /\.html$/,
|
|
246
|
-
loader: require.resolve('html-loader')
|
|
247
227
|
}
|
|
248
228
|
]
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
test: /\.(jpg|png|gif|webp|bmp|jpeg|svg)$/,
|
|
232
|
+
type: 'asset',
|
|
233
|
+
generator: {
|
|
234
|
+
filename: 'images/[name]_[contenthash][ext]'
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
test: /\.(otf|eot|woff2?|ttf)$/i,
|
|
239
|
+
type: 'asset',
|
|
240
|
+
generator: {
|
|
241
|
+
filename: 'fonts/[name]_[contenthash][ext]'
|
|
242
|
+
}
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
test: /\.(txt|xml)$/i,
|
|
246
|
+
type: 'asset/source'
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
test: /\.html$/,
|
|
250
|
+
loader: require.resolve('html-loader')
|
|
249
251
|
}
|
|
250
252
|
]
|
|
251
253
|
},
|
|
@@ -256,13 +258,17 @@ function default_1({ projectPath, entryPath, env, customConfig }) {
|
|
|
256
258
|
externals: customConfig.base.externals,
|
|
257
259
|
plugins: [
|
|
258
260
|
...basicPlugins,
|
|
261
|
+
new core_1.CssExtractRspackPlugin({
|
|
262
|
+
filename: env === 'dev' ? 'css/[name].css' : 'css/[name].[contenthash].css',
|
|
263
|
+
ignoreOrder: true
|
|
264
|
+
}),
|
|
259
265
|
new vue_loader_1.VueLoaderPlugin(),
|
|
260
|
-
new core_1.
|
|
266
|
+
new core_1.DefinePlugin({
|
|
261
267
|
__VUE_OPTIONS_API__: true,
|
|
262
268
|
__VUE_PROD_DEVTOOLS__: false,
|
|
263
269
|
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: false
|
|
264
270
|
}),
|
|
265
|
-
new core_1.
|
|
271
|
+
new core_1.HtmlRspackPlugin({
|
|
266
272
|
template: path_1.default.join(projectPath, '/src/index.ejs'),
|
|
267
273
|
filename: 'index.html',
|
|
268
274
|
minify: true,
|
|
@@ -272,13 +278,8 @@ function default_1({ projectPath, entryPath, env, customConfig }) {
|
|
|
272
278
|
},
|
|
273
279
|
hash: true
|
|
274
280
|
}),
|
|
275
|
-
new core_1.CssExtractRspackPlugin({
|
|
276
|
-
filename: env === 'dev' ? 'css/[name].css' : 'css/[name].[contenthash].css',
|
|
277
|
-
ignoreOrder: true
|
|
278
|
-
}),
|
|
279
281
|
...((customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.plugins) || config_1.initConfig.plugins)
|
|
280
282
|
]
|
|
281
283
|
};
|
|
282
284
|
});
|
|
283
285
|
}
|
|
284
|
-
exports.default = default_1;
|
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
36
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
37
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -35,27 +45,30 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
35
45
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
46
|
};
|
|
37
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
+
exports.default = default_1;
|
|
38
49
|
const webpack_bundle_analyzer_1 = __importDefault(require("webpack-bundle-analyzer"));
|
|
39
50
|
const path_1 = __importDefault(require("path"));
|
|
40
51
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
41
52
|
const config_1 = require("../utils/config");
|
|
42
53
|
const webpack_merge_1 = require("webpack-merge");
|
|
43
|
-
const webpackbar_1 = __importDefault(require("webpackbar"));
|
|
44
|
-
const tools_1 = require("../utils/tools");
|
|
45
54
|
const core_1 = require("@rspack/core");
|
|
46
55
|
const BundleAnalyzerPlugin = webpack_bundle_analyzer_1.default.BundleAnalyzerPlugin;
|
|
47
56
|
const isAnalyze = process.env.ANALYZE === 'true';
|
|
48
57
|
function default_1(options) {
|
|
49
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
50
58
|
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
51
60
|
const { projectPath, customConfig, templateType } = options;
|
|
52
|
-
const getBaseConfig = (yield Promise.resolve(`${templateType === 'vue' ? './
|
|
61
|
+
const getBaseConfig = (yield Promise.resolve(`${templateType === 'vue' ? './rspack.base.vue' : './rspack.base.react'}`).then(s => __importStar(require(s)))).default;
|
|
53
62
|
const baseConfig = yield getBaseConfig(Object.assign(Object.assign({}, options), { env: 'prod' }));
|
|
54
63
|
const consoleAvailable = (_b = (_a = customConfig.prod) === null || _a === void 0 ? void 0 : _a.console) !== null && _b !== void 0 ? _b : config_1.initConfig.console;
|
|
55
64
|
const isPublicDirExist = yield fs_extra_1.default.exists(path_1.default.join(projectPath, '/public'));
|
|
56
65
|
const copyConfig = (_d = (_c = customConfig.prod) === null || _c === void 0 ? void 0 : _c.copy) !== null && _d !== void 0 ? _d : config_1.initConfig.copy;
|
|
57
66
|
const customDevtool = (_e = customConfig.prod.devtool) !== null && _e !== void 0 ? _e : customConfig.base.devtool;
|
|
58
67
|
return (0, webpack_merge_1.merge)(baseConfig, {
|
|
68
|
+
output: {
|
|
69
|
+
cssFilename: 'css/[name].[contenthash].css',
|
|
70
|
+
cssChunkFilename: 'css/[name].[contenthash].css'
|
|
71
|
+
},
|
|
59
72
|
performance: {
|
|
60
73
|
hints: false
|
|
61
74
|
},
|
|
@@ -64,24 +77,22 @@ function default_1(options) {
|
|
|
64
77
|
optimization: {
|
|
65
78
|
runtimeChunk: true,
|
|
66
79
|
minimize: true,
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
priority: -20,
|
|
80
|
-
chunks: 'all',
|
|
81
|
-
reuseExistingChunk: true
|
|
80
|
+
minimizer: [
|
|
81
|
+
new core_1.rspack.SwcJsMinimizerRspackPlugin({
|
|
82
|
+
minimizerOptions: {
|
|
83
|
+
minify: true,
|
|
84
|
+
mangle: true,
|
|
85
|
+
compress: {
|
|
86
|
+
passes: 2,
|
|
87
|
+
drop_console: !consoleAvailable
|
|
88
|
+
},
|
|
89
|
+
format: {
|
|
90
|
+
comments: false
|
|
91
|
+
}
|
|
82
92
|
}
|
|
83
|
-
}
|
|
84
|
-
|
|
93
|
+
}),
|
|
94
|
+
new core_1.rspack.LightningCssMinimizerRspackPlugin({})
|
|
95
|
+
]
|
|
85
96
|
},
|
|
86
97
|
plugins: [
|
|
87
98
|
...(isPublicDirExist || copyConfig.length > 0
|
|
@@ -110,14 +121,8 @@ function default_1(options) {
|
|
|
110
121
|
})
|
|
111
122
|
]
|
|
112
123
|
: []),
|
|
113
|
-
new webpackbar_1.default({
|
|
114
|
-
name: 'Swico',
|
|
115
|
-
color: tools_1.colorConfig.theme,
|
|
116
|
-
profile: false
|
|
117
|
-
}),
|
|
118
124
|
...((_g = (_f = customConfig.prod) === null || _f === void 0 ? void 0 : _f.plugins) !== null && _g !== void 0 ? _g : [])
|
|
119
125
|
]
|
|
120
126
|
});
|
|
121
127
|
});
|
|
122
128
|
}
|
|
123
|
-
exports.default = default_1;
|
package/src/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { GlobalData, GlobalSwicoConfigType } from './utils/config';
|
|
2
2
|
import { UseLocationType, UseNavType } from './typings/global-type';
|
|
3
|
+
export { rspack } from '@rspack/core';
|
|
3
4
|
export type CustomConfigType = GlobalData['customConfig'];
|
|
4
5
|
export type { GlobalSwicoConfigType };
|
|
5
6
|
export { history } from './mock-history';
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.defineGlobal = exports.defineConfig = exports.useNav = exports.useLocation = exports.Link = exports.Outlet = exports.history = void 0;
|
|
3
|
+
exports.defineGlobal = exports.defineConfig = exports.useNav = exports.useLocation = exports.Link = exports.Outlet = exports.history = exports.rspack = void 0;
|
|
4
|
+
var core_1 = require("@rspack/core");
|
|
5
|
+
Object.defineProperty(exports, "rspack", { enumerable: true, get: function () { return core_1.rspack; } });
|
|
4
6
|
var mock_history_1 = require("./mock-history");
|
|
5
7
|
Object.defineProperty(exports, "history", { enumerable: true, get: function () { return mock_history_1.history; } });
|
|
6
8
|
let Outlet, Link, useLocation, useNav;
|
package/src/index.react.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { GlobalData, GlobalSwicoConfigType } from './utils/config';
|
|
2
2
|
import { CSSProperties, FC, ReactNode } from 'react';
|
|
3
|
+
export { rspack } from '@rspack/core';
|
|
3
4
|
export type CustomConfigType = GlobalData['customConfig'];
|
|
4
5
|
export type { GlobalSwicoConfigType };
|
|
5
6
|
export declare const Link: FC<{
|
|
@@ -9,7 +10,7 @@ export declare const Link: FC<{
|
|
|
9
10
|
className?: string;
|
|
10
11
|
children: ReactNode;
|
|
11
12
|
}>;
|
|
12
|
-
export { Outlet } from 'react-router
|
|
13
|
+
export { Outlet } from 'react-router';
|
|
13
14
|
export { useLocation, useNav } from './project-path/.swico-react/react-hooks';
|
|
14
15
|
export { history } from './mock-history';
|
|
15
16
|
export interface DefineSwicoConfigType {
|
|
@@ -18,6 +19,5 @@ export interface DefineSwicoConfigType {
|
|
|
18
19
|
(env: 'prod', config: CustomConfigType['prod']): any;
|
|
19
20
|
}
|
|
20
21
|
export declare const defineConfig: DefineSwicoConfigType;
|
|
21
|
-
export
|
|
22
|
-
}
|
|
22
|
+
export type DefineGlobalConfigType = object;
|
|
23
23
|
export declare const defineGlobal: (config: DefineGlobalConfigType) => DefineGlobalConfigType;
|
package/src/index.react.js
CHANGED
|
@@ -3,13 +3,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.defineGlobal = exports.defineConfig = exports.history = exports.useNav = exports.useLocation = exports.Outlet = exports.Link = void 0;
|
|
7
|
-
const
|
|
6
|
+
exports.defineGlobal = exports.defineConfig = exports.history = exports.useNav = exports.useLocation = exports.Outlet = exports.Link = exports.rspack = void 0;
|
|
7
|
+
const react_router_1 = require("react-router");
|
|
8
8
|
const react_1 = __importDefault(require("react"));
|
|
9
|
-
|
|
9
|
+
var core_1 = require("@rspack/core");
|
|
10
|
+
Object.defineProperty(exports, "rspack", { enumerable: true, get: function () { return core_1.rspack; } });
|
|
11
|
+
const Link = ({ replace, to, style, className, children }) => react_1.default.createElement(react_router_1.Link, { replace, to, style, className }, children);
|
|
10
12
|
exports.Link = Link;
|
|
11
|
-
var
|
|
12
|
-
Object.defineProperty(exports, "Outlet", { enumerable: true, get: function () { return
|
|
13
|
+
var react_router_2 = require("react-router");
|
|
14
|
+
Object.defineProperty(exports, "Outlet", { enumerable: true, get: function () { return react_router_2.Outlet; } });
|
|
13
15
|
var react_hooks_1 = require("./project-path/.swico-react/react-hooks");
|
|
14
16
|
Object.defineProperty(exports, "useLocation", { enumerable: true, get: function () { return react_hooks_1.useLocation; } });
|
|
15
17
|
Object.defineProperty(exports, "useNav", { enumerable: true, get: function () { return react_hooks_1.useNav; } });
|
package/src/index.vue.d.ts
CHANGED
|
@@ -5,24 +5,27 @@ export type CustomConfigType = GlobalData['customConfig'];
|
|
|
5
5
|
export { RouterView as Outlet } from 'vue-router';
|
|
6
6
|
export { useLocation, useNav } from './project-path/.swico-vue/vue-hooks';
|
|
7
7
|
export { history } from './mock-history';
|
|
8
|
+
export { rspack } from '@rspack/core';
|
|
8
9
|
export type { GlobalSwicoConfigType };
|
|
9
|
-
export declare const Link: import("vue").DefineComponent<{
|
|
10
|
+
export declare const Link: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
10
11
|
to: {
|
|
11
12
|
type: StringConstructor;
|
|
12
13
|
};
|
|
13
14
|
replace: {
|
|
14
15
|
type: BooleanConstructor;
|
|
15
16
|
};
|
|
16
|
-
}
|
|
17
|
+
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
17
18
|
to: {
|
|
18
19
|
type: StringConstructor;
|
|
19
20
|
};
|
|
20
21
|
replace: {
|
|
21
22
|
type: BooleanConstructor;
|
|
22
23
|
};
|
|
23
|
-
}
|
|
24
|
+
}>> & Readonly<{}>, {
|
|
24
25
|
replace: boolean;
|
|
25
|
-
}, {}
|
|
26
|
+
}, {}, {
|
|
27
|
+
RouterLink: import("vue-router")._RouterLinkI;
|
|
28
|
+
}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
26
29
|
export interface DefineSwicoConfigType {
|
|
27
30
|
(env: 'base', config: CustomConfigType['base']): any;
|
|
28
31
|
(env: 'dev', config: CustomConfigType['dev']): any;
|
package/src/index.vue.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.defineGlobal = exports.defineConfig = exports.Link = exports.history = exports.useNav = exports.useLocation = exports.Outlet = void 0;
|
|
3
|
+
exports.defineGlobal = exports.defineConfig = exports.Link = exports.rspack = exports.history = exports.useNav = exports.useLocation = exports.Outlet = void 0;
|
|
4
4
|
const vue_1 = require("vue");
|
|
5
5
|
const vue_router_1 = require("vue-router");
|
|
6
6
|
var vue_router_2 = require("vue-router");
|
|
@@ -10,6 +10,8 @@ Object.defineProperty(exports, "useLocation", { enumerable: true, get: function
|
|
|
10
10
|
Object.defineProperty(exports, "useNav", { enumerable: true, get: function () { return vue_hooks_1.useNav; } });
|
|
11
11
|
var mock_history_1 = require("./mock-history");
|
|
12
12
|
Object.defineProperty(exports, "history", { enumerable: true, get: function () { return mock_history_1.history; } });
|
|
13
|
+
var core_1 = require("@rspack/core");
|
|
14
|
+
Object.defineProperty(exports, "rspack", { enumerable: true, get: function () { return core_1.rspack; } });
|
|
13
15
|
exports.Link = (0, vue_1.defineComponent)({
|
|
14
16
|
components: {
|
|
15
17
|
RouterLink: vue_router_1.RouterLink
|
|
@@ -31,7 +31,7 @@ exports.compareURLPatterns = compareURLPatterns;
|
|
|
31
31
|
const interpolatePath = (pathTemplate, params) => {
|
|
32
32
|
const pathParts = pathTemplate.split('/');
|
|
33
33
|
const interpolatedParts = pathParts.map((part) => {
|
|
34
|
-
const paramMatch = part.match(
|
|
34
|
+
const paramMatch = part.match(/^:(.+)$/);
|
|
35
35
|
if (paramMatch) {
|
|
36
36
|
const paramName = paramMatch[1];
|
|
37
37
|
if (params[paramName]) {
|
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
37
|
};
|
|
@@ -29,7 +39,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
29
39
|
exports.getChildrenRouteList = void 0;
|
|
30
40
|
const client_1 = require("react-dom/client");
|
|
31
41
|
const react_1 = __importStar(require("react"));
|
|
32
|
-
const
|
|
42
|
+
const react_router_1 = require("react-router");
|
|
33
43
|
const loading_1 = __importDefault(require("../loading"));
|
|
34
44
|
const history_1 = require("./history");
|
|
35
45
|
require("../../src/global");
|
|
@@ -57,7 +67,7 @@ const getChildrenRouteList = (childrenRoutes, ancPathKey) => {
|
|
|
57
67
|
const { component, path, children, redirect } = item;
|
|
58
68
|
const newAncPathKey = `${ancPathKey}-${path}`;
|
|
59
69
|
return {
|
|
60
|
-
element: redirect ? (react_1.default.createElement(
|
|
70
|
+
element: redirect ? (react_1.default.createElement(react_router_1.Navigate, { to: redirect, replace: true })) : component ? (react_1.default.createElement(react_1.Suspense, { fallback: react_1.default.createElement(loading_1.default, null) }, (0, react_1.createElement)((0, react_1.lazy)(component)))) : (react_1.default.createElement(react_router_1.Outlet, null)),
|
|
61
71
|
key: newAncPathKey,
|
|
62
72
|
path: path.startsWith('/') ? path.slice(1) : path,
|
|
63
73
|
children: (0, exports.getChildrenRouteList)(children, newAncPathKey)
|
|
@@ -74,7 +84,7 @@ const App = () => {
|
|
|
74
84
|
children: (0, exports.getChildrenRouteList)(routes_1.default, '')
|
|
75
85
|
}
|
|
76
86
|
];
|
|
77
|
-
const router = (config_1.routerType === 'hash' ?
|
|
87
|
+
const router = (config_1.routerType === 'hash' ? react_router_1.createHashRouter : react_router_1.createBrowserRouter)(routeList, {
|
|
78
88
|
basename: config_1.routerBase
|
|
79
89
|
});
|
|
80
90
|
if (config_1.routerBase && config_1.routerBase !== '/') {
|
|
@@ -85,7 +95,7 @@ const App = () => {
|
|
|
85
95
|
(0, react_1.useLayoutEffect)(() => {
|
|
86
96
|
history_1.history = (0, history_1.getHistory)(router);
|
|
87
97
|
});
|
|
88
|
-
return react_1.default.createElement(
|
|
98
|
+
return react_1.default.createElement(react_router_1.RouterProvider, { router: router });
|
|
89
99
|
};
|
|
90
100
|
const root = (0, client_1.createRoot)(document.getElementById('root'));
|
|
91
101
|
root.render(react_1.default.createElement(App, null));
|
|
@@ -4,13 +4,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.useNav = exports.useLocation = void 0;
|
|
7
|
-
const
|
|
7
|
+
const react_router_1 = require("react-router");
|
|
8
8
|
const history_1 = require("./$env/history");
|
|
9
9
|
const qs_1 = __importDefault(require("qs"));
|
|
10
10
|
const useLocation = () => {
|
|
11
11
|
var _a;
|
|
12
|
-
const location = (0,
|
|
13
|
-
const params = (0,
|
|
12
|
+
const location = (0, react_router_1.useLocation)();
|
|
13
|
+
const params = (0, react_router_1.useParams)();
|
|
14
14
|
const { search, hash, pathname, state } = location;
|
|
15
15
|
const matchItem = history_1.pathNameList.find((item) => (Object.keys(params).length > 0 && (0, history_1.compareURLPatterns)(pathname, item.path)) ||
|
|
16
16
|
item.path === pathname);
|
|
@@ -39,7 +39,7 @@ const getFormatNavPath = (to) => {
|
|
|
39
39
|
return newPath;
|
|
40
40
|
};
|
|
41
41
|
const useNav = () => {
|
|
42
|
-
const navigate = (0,
|
|
42
|
+
const navigate = (0, react_router_1.useNavigate)();
|
|
43
43
|
const newNavigate = (to, options) => {
|
|
44
44
|
switch (typeof to) {
|
|
45
45
|
case 'string':
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").
|
|
1
|
+
declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
2
|
export default _default;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").
|
|
1
|
+
declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
2
|
export default _default;
|
|
@@ -3,6 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
6
|
+
const react_router_1 = require("react-router");
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
|
-
exports.default = () => react_1.default.createElement(
|
|
8
|
+
exports.default = () => react_1.default.createElement(react_router_1.Outlet, null);
|
package/src/utils/config.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export interface GlobalSwicoConfigType {
|
|
|
20
20
|
console?: boolean;
|
|
21
21
|
define?: Record<string, any>;
|
|
22
22
|
alias?: Record<string, any>;
|
|
23
|
-
proxy?: Record<string, any
|
|
23
|
+
proxy?: Array<Record<string, any>>;
|
|
24
24
|
https?: boolean;
|
|
25
25
|
copy?: Array<string | {
|
|
26
26
|
from: string;
|
package/src/utils/config.js
CHANGED
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
36
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
37
|
return new (P || (P = Promise))(function (resolve, reject) {
|
package/src/utils/tools.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ConfigRouterType } from './config';
|
|
2
2
|
export declare const copyDirFiles: (src: any, dest: any, filter?: (fileName: any) => boolean) => Promise<void>;
|
|
3
|
-
export declare const getFormatRouter: (projectPath: string, routes: ConfigRouterType[
|
|
3
|
+
export declare const getFormatRouter: (projectPath: string, routes: ConfigRouterType["routes"], templateType: any) => any[];
|
|
4
4
|
export declare const getPort: () => Promise<number>;
|
|
5
5
|
export declare const colorConfig: {
|
|
6
6
|
theme: string;
|
package/src/utils/tools.js
CHANGED
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
36
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
37
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -141,14 +151,14 @@ exports.toast = {
|
|
|
141
151
|
else {
|
|
142
152
|
if (Array.isArray(message)) {
|
|
143
153
|
if (message.length > 0) {
|
|
144
|
-
console.log(`${chalk_1.default.red.bold('error')} - ${title || '
|
|
154
|
+
console.log(`${chalk_1.default.red.bold('error')} - ${title || 'Swico errors'}:`);
|
|
145
155
|
}
|
|
146
156
|
message.forEach((item) => {
|
|
147
157
|
console.log(`> ${chalk_1.default.red.bold(item)}`);
|
|
148
158
|
});
|
|
149
159
|
}
|
|
150
160
|
else if (message) {
|
|
151
|
-
console.log(`${chalk_1.default.red.bold('error')} - ${title || '
|
|
161
|
+
console.log(`${chalk_1.default.red.bold('error')} - ${title || 'Swico errors'}:`);
|
|
152
162
|
console.log(`> ${chalk_1.default.red.bold(message)}`);
|
|
153
163
|
}
|
|
154
164
|
}
|
|
@@ -160,7 +170,7 @@ exports.toast = {
|
|
|
160
170
|
console.log(`${chalk_1.default.hex(color).bold('warning')} - ${message}`);
|
|
161
171
|
}
|
|
162
172
|
else {
|
|
163
|
-
console.log(`${chalk_1.default.hex(color).bold('warning')} - ${title || '
|
|
173
|
+
console.log(`${chalk_1.default.hex(color).bold('warning')} - ${title || ' Swico warnings'}:`);
|
|
164
174
|
if (Array.isArray(message)) {
|
|
165
175
|
message.forEach((item) => {
|
|
166
176
|
console.log(`> ${chalk_1.default.hex(color).bold(item)}`);
|
|
@@ -181,7 +191,6 @@ const initIndexFile = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
181
191
|
.replaceAll('\\', '/');
|
|
182
192
|
if (fileText.includes(`require("${formatHooksPath}");`)) {
|
|
183
193
|
fileText = fileText.replaceAll(`require("${formatHooksPath}");`, 'require("./project-path/.swico-react/react-hooks");');
|
|
184
|
-
yield fs_extra_1.default.writeFile(targetPath, fileText);
|
|
185
194
|
}
|
|
186
195
|
const formatDevHistoryPath = path_1.default
|
|
187
196
|
.resolve(projectPath, './.swico/.dev/history')
|
|
@@ -191,11 +200,10 @@ const initIndexFile = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
191
200
|
.replaceAll('\\', '/');
|
|
192
201
|
if (fileText.includes(`require("${formatDevHistoryPath}");`)) {
|
|
193
202
|
fileText = fileText.replaceAll(`require("${formatDevHistoryPath}");`, 'require("./mock-history");');
|
|
194
|
-
yield fs_extra_1.default.writeFile(targetPath, fileText);
|
|
195
203
|
}
|
|
196
204
|
else if (fileText.includes(`require("${formatProdHistoryPath}");`)) {
|
|
197
205
|
fileText = fileText.replaceAll(`require("${formatProdHistoryPath}");`, 'require("./mock-history");');
|
|
198
|
-
yield fs_extra_1.default.writeFile(targetPath, fileText);
|
|
199
206
|
}
|
|
207
|
+
yield fs_extra_1.default.writeFile(targetPath, fileText);
|
|
200
208
|
});
|
|
201
209
|
exports.initIndexFile = initIndexFile;
|