新建nestJS项目
import { NestExpressApplication } from '@nestjs/platform-express';
import * as path from 'path';
const app = await NestFactory.create<NestExpressApplication>(AppModule, {
logger: true,
});
app.useStaticAssets(path.join(__dirname, '..', 'public'));
app.setBaseViewsDir(path.join(__dirname, '..', 'views'));
app.setViewEngine('hbs');
app.setGlobalPrefix('/react-ant-admin');
import { Response } from 'express';
import * as path from 'path';
getHello(@Res() res: Response): any {
res.sendFile(
path.join(__dirname, '../public/react-ant-admin', 'index.html'),
);
}
}
静态资源放置
项目运行
- 浏览器输入:
http://localhost:3000/react-ant-admin/