mirror of
https://github.com/Shadowfita/docmost.git
synced 2025-11-12 15:52:32 +10:00
Make ServeStatic dynamic
This commit is contained in:
@ -8,6 +8,20 @@ import { WsModule } from './ws/ws.module';
|
|||||||
import { ServeStaticModule } from '@nestjs/serve-static';
|
import { ServeStaticModule } from '@nestjs/serve-static';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import { KyselyDbModule } from './kysely/kysely-db.module';
|
import { KyselyDbModule } from './kysely/kysely-db.module';
|
||||||
|
import * as fs from 'fs';
|
||||||
|
|
||||||
|
const clientDistPath = join(__dirname, '..', '..', 'client/dist');
|
||||||
|
|
||||||
|
function getServeStaticModule() {
|
||||||
|
if (fs.existsSync(clientDistPath)) {
|
||||||
|
return [
|
||||||
|
ServeStaticModule.forRoot({
|
||||||
|
rootPath: clientDistPath,
|
||||||
|
}),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
@ -16,9 +30,7 @@ import { KyselyDbModule } from './kysely/kysely-db.module';
|
|||||||
EnvironmentModule,
|
EnvironmentModule,
|
||||||
CollaborationModule,
|
CollaborationModule,
|
||||||
WsModule,
|
WsModule,
|
||||||
ServeStaticModule.forRoot({
|
...getServeStaticModule(),
|
||||||
rootPath: join(__dirname, '..', '..', '..', 'client/dist'),
|
|
||||||
}),
|
|
||||||
],
|
],
|
||||||
controllers: [AppController],
|
controllers: [AppController],
|
||||||
providers: [AppService],
|
providers: [AppService],
|
||||||
|
|||||||
Reference in New Issue
Block a user