@ray-js/build-plugin-router 1.3.99-beta.0 → 1.3.99-beta.2
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/index.js +7 -6
- package/package.json +4 -4
package/lib/index.js
CHANGED
@@ -169,6 +169,7 @@ function PluginRouter(api) {
|
|
169
169
|
let cacheThemeLocation = {};
|
170
170
|
let timerId;
|
171
171
|
let themeLocation;
|
172
|
+
const { source } = api.options;
|
172
173
|
const plugin = {
|
173
174
|
name: '@ray-js/build-plugin-router',
|
174
175
|
setup() {
|
@@ -177,10 +178,10 @@ function PluginRouter(api) {
|
|
177
178
|
if (api.options.watch) {
|
178
179
|
chokidar_1.default
|
179
180
|
.watch(['**/*.config.ts', '**/*.config.js', '!app.config.{js,ts}'], {
|
180
|
-
cwd: path_1.default.join(api.options.cwd,
|
181
|
+
cwd: path_1.default.join(api.options.cwd, source),
|
181
182
|
})
|
182
183
|
.on('change', (file) => {
|
183
|
-
const filePath = path_1.default.join(api.options.cwd,
|
184
|
+
const filePath = path_1.default.join(api.options.cwd, source, file);
|
184
185
|
// 配置文件引用存在 cache
|
185
186
|
delete require.cache[require.resolve(filePath)];
|
186
187
|
// FIXME: 引用文件变更也需要重新构建
|
@@ -189,11 +190,11 @@ function PluginRouter(api) {
|
|
189
190
|
}
|
190
191
|
},
|
191
192
|
readConfigFromConfigFile() {
|
192
|
-
const routesConfigFile = api.searchJSFile(
|
193
|
+
const routesConfigFile = api.searchJSFile(`${source}/routes.config`);
|
193
194
|
if (!routesConfigFile) {
|
194
195
|
throw new Error(`missing configuration file (routes.config.{ts|js})`);
|
195
196
|
}
|
196
|
-
const globalConfigFile = api.searchJSFile(
|
197
|
+
const globalConfigFile = api.searchJSFile(`${source}/global.config`);
|
197
198
|
const routesConfig = api.requireJSFile(routesConfigFile);
|
198
199
|
const globalConfig = globalConfigFile ? api.requireJSFile(globalConfigFile, '*') : {};
|
199
200
|
return { routesConfig, globalConfig };
|
@@ -281,8 +282,8 @@ function PluginRouter(api) {
|
|
281
282
|
}
|
282
283
|
const templateFile = path_1.default.join(__dirname, '../templates/app.config.ejs');
|
283
284
|
const context = ejsRender(templateFile, { appConfig: { [target]: data } });
|
284
|
-
api.writeFile(
|
285
|
-
shared_1.log.verbose(LOG_PREFIX, `generate`,
|
285
|
+
api.writeFile(`${source}/app.config.ts`, context);
|
286
|
+
shared_1.log.verbose(LOG_PREFIX, `generate`, `${source}/app.config.ts`.underline.green, `for wechat platform`);
|
286
287
|
},
|
287
288
|
};
|
288
289
|
// todo theme 逻辑不应该在这个文件
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ray-js/build-plugin-router",
|
3
|
-
"version": "1.3.99-beta.
|
3
|
+
"version": "1.3.99-beta.2",
|
4
4
|
"description": "Ray build plugin for router",
|
5
5
|
"keywords": [
|
6
6
|
"ray"
|
@@ -21,7 +21,7 @@
|
|
21
21
|
"watch": "tsc -p ./tsconfig.build.json --watch"
|
22
22
|
},
|
23
23
|
"dependencies": {
|
24
|
-
"@ray-js/shared": "^1.3.99-beta.
|
24
|
+
"@ray-js/shared": "^1.3.99-beta.2",
|
25
25
|
"chokidar": "^3.5.2",
|
26
26
|
"colors": "1.4.0",
|
27
27
|
"ejs": "^3.1.6",
|
@@ -30,7 +30,7 @@
|
|
30
30
|
"url": "^0.11.0"
|
31
31
|
},
|
32
32
|
"devDependencies": {
|
33
|
-
"@ray-js/types": "^1.3.99-beta.
|
33
|
+
"@ray-js/types": "^1.3.99-beta.2"
|
34
34
|
},
|
35
35
|
"maintainers": [
|
36
36
|
{
|
@@ -38,6 +38,6 @@
|
|
38
38
|
"email": "tuyafe@tuya.com"
|
39
39
|
}
|
40
40
|
],
|
41
|
-
"gitHead": "
|
41
|
+
"gitHead": "c129b96e800e9bb062bdbb1236c05cb800fdc34b",
|
42
42
|
"repository": {}
|
43
43
|
}
|