Created
November 5, 2020 21:14
-
-
Save beeman/bea91efb39f2c2476c16e5113a98c825 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Logger, Module } from '@nestjs/common' | |
import { ServeStaticModule } from '@nestjs/serve-static' | |
import { ensureDirSync, existsSync, writeFileSync } from 'fs-extra' | |
import { join } from 'path' | |
const rootPath = join(__dirname, '..', 'admin') | |
@Module({ | |
imports: [ | |
// Feature modules here... | |
ServeStaticModule.forRoot({ | |
rootPath, | |
exclude: ['/api', '/graphql'], | |
}), | |
], | |
}) | |
export class AppModule { | |
constructor() { | |
if (!existsSync(rootPath)) { | |
ensureDirSync(rootPath) | |
writeFileSync(join(rootPath, 'index.html'), `<pre>Run 'yarn build:admin' to build the frontend.</pre>`) | |
Logger.verbose(`Created static root path ${rootPath}`) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment