feat(generator): add nojekyll option (#8813)

Co-authored-by: Xin Du (Clark) <clark.duxin@gmail.com>
This commit is contained in:
Amon Sawamura 2021-02-25 06:01:01 +09:00 committed by GitHub
parent 931d1cf89e
commit 380ffb6481
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 10 additions and 2 deletions

View File

@ -8,6 +8,7 @@ export default () => ({
fallback: '200.html',
crawler: true,
manifest: true,
nojekyll: true,
cache: {
ignore: [],
globbyOptions: {

View File

@ -218,6 +218,7 @@ Object {
"fallback": "200.html",
"interval": 0,
"manifest": true,
"nojekyll": true,
"routes": Array [],
"staticAssets": Object {
"base": "/_nuxt/static",

View File

@ -193,6 +193,7 @@ Object {
"fallback": "200.html",
"interval": 0,
"manifest": true,
"nojekyll": true,
"routes": Array [],
"staticAssets": Object {
"base": undefined,
@ -578,6 +579,7 @@ Object {
"fallback": "200.html",
"interval": 0,
"manifest": true,
"nojekyll": true,
"routes": Array [],
"staticAssets": Object {
"base": undefined,

View File

@ -267,8 +267,10 @@ export default class Generator {
// Add .nojekyll file to let GitHub Pages add the _nuxt/ folder
// https://help.github.com/articles/files-that-start-with-an-underscore-are-missing/
if (this.options.generate.nojekyll) {
const nojekyllPath = path.resolve(this.distPath, '.nojekyll')
await fsExtra.writeFile(nojekyllPath, '')
}
await this.nuxt.callHook('generate:distCopied', this)
await this.nuxt.callHook('export:distCopied', this)

View File

@ -182,6 +182,7 @@ describe('generator: initialize', () => {
test('should initialize destination folder', async () => {
const nuxt = createNuxt()
nuxt.options.generate.fallback = 'fallback.html'
nuxt.options.generate.nojekyll = true
const generator = new Generator(nuxt)
fsExtra.exists.mockReturnValueOnce(false)

View File

@ -18,6 +18,7 @@ export interface NuxtOptionsGenerate {
exclude?: RegExp[]
fallback?: string | boolean
interval?: number
nojekyll?: boolean
routes?: NuxtOptionsGenerateRoute[] | NuxtOptionsGenerateRoutesFunction | NuxtOptionsGenerateRoutesFunctionWithCallback
subFolders?: boolean
cache?: false | {