This commit is contained in:
winixt 2021-12-22 20:10:38 +08:00
parent fd318c62e3
commit 37a303c11e
2 changed files with 13 additions and 5 deletions

View File

@ -3,6 +3,16 @@ import { join } from 'path';
import { winPath } from '@fesjs/utils'; import { winPath } from '@fesjs/utils';
import { runtimePath } from '../../../../utils/constants'; import { runtimePath } from '../../../../utils/constants';
function getAppPath(absSrcPath) {
for (const suffix of ['.js', '.ts', '.jsm']) {
const p = winPath(join(absSrcPath, `app${suffix}`));
if (existsSync(p)) {
return p;
}
}
return null;
}
export default function (api) { export default function (api) {
const { const {
paths, paths,
@ -33,12 +43,11 @@ export default function (api) {
'onRouterCreated' 'onRouterCreated'
] ]
}); });
const appPath = winPath(join(paths.absSrcPath, 'app.js'));
const plugins = await api.applyPlugins({ const plugins = await api.applyPlugins({
key: 'addRuntimePlugin', key: 'addRuntimePlugin',
type: api.ApplyPluginsType.add, type: api.ApplyPluginsType.add,
initialValue: [ initialValue: [
existsSync(appPath) && appPath getAppPath(paths.absSrcPath)
].filter(Boolean) ].filter(Boolean)
}); });
api.writeTmpFile({ api.writeTmpFile({

View File

@ -44,9 +44,8 @@ export default async ({ api, watch }) => {
type: api.ApplyPluginsType.add, type: api.ApplyPluginsType.add,
initialValue: [ initialValue: [
paths.absPagesPath, paths.absPagesPath,
// 貌似没用到 join(paths.absSrcPath, 'app.js'),
// join(paths.absSrcPath, api.config?.singular ? 'layout' : 'layouts'), join(paths.absSrcPath, 'app.ts')
join(paths.absSrcPath, 'app.js')
] ]
}); });
lodash lodash