mirror of
https://github.com/WeBankFinTech/fes.js.git
synced 2025-04-06 03:59:53 +08:00
feat: app 入口文件支持 .tsx, .jsx 后缀
This commit is contained in:
parent
86888e1887
commit
b4c74e660e
@ -1,17 +1,9 @@
|
|||||||
import { readFileSync, existsSync } from 'fs';
|
import { readFileSync } from 'fs';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import { winPath } from '@fesjs/utils';
|
import { winPath } from '@fesjs/utils';
|
||||||
import { runtimePath } from '../../../../utils/constants';
|
import { runtimePath } from '../../../../utils/constants';
|
||||||
|
import { getAppPath } from '../../../../utils/getAppEntryPath';
|
||||||
|
|
||||||
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 {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { chokidar, lodash, winPath } from '@fesjs/utils';
|
import { chokidar, lodash, winPath } from '@fesjs/utils';
|
||||||
import { join } from 'path';
|
import { getAppPath } from './getAppEntryPath';
|
||||||
|
|
||||||
export default async ({ api, watch }) => {
|
export default async ({ api, watch }) => {
|
||||||
const { paths } = api;
|
const { paths } = api;
|
||||||
@ -44,8 +44,7 @@ export default async ({ api, watch }) => {
|
|||||||
type: api.ApplyPluginsType.add,
|
type: api.ApplyPluginsType.add,
|
||||||
initialValue: [
|
initialValue: [
|
||||||
paths.absPagesPath,
|
paths.absPagesPath,
|
||||||
join(paths.absSrcPath, 'app.js'),
|
getAppPath(paths.absSrcPath)
|
||||||
join(paths.absSrcPath, 'app.ts')
|
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
lodash
|
lodash
|
||||||
|
13
packages/fes-preset-built-in/src/utils/getAppEntryPath.js
Normal file
13
packages/fes-preset-built-in/src/utils/getAppEntryPath.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import { join } from 'path';
|
||||||
|
import { existsSync } from 'fs';
|
||||||
|
import { winPath } from '@fesjs/utils';
|
||||||
|
|
||||||
|
export function getAppPath(absSrcPath) {
|
||||||
|
for (const suffix of ['.js', '.ts', '.jsm', '.jsx', '.tsx']) {
|
||||||
|
const p = winPath(join(absSrcPath, `app${suffix}`));
|
||||||
|
if (existsSync(p)) {
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user