From 380ffb6481ad9c4f68b7d0a4927bd61aaf27a9e7 Mon Sep 17 00:00:00 2001 From: Amon Sawamura Date: Thu, 25 Feb 2021 06:01:01 +0900 Subject: [PATCH] feat(generator): add nojekyll option (#8813) Co-authored-by: Xin Du (Clark) --- packages/config/src/config/generate.js | 1 + packages/config/test/__snapshots__/options.test.js.snap | 1 + .../config/test/config/__snapshots__/index.test.js.snap | 2 ++ packages/generator/src/generator.js | 6 ++++-- packages/generator/test/generator.init.test.js | 1 + packages/types/config/generate.d.ts | 1 + 6 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/config/src/config/generate.js b/packages/config/src/config/generate.js index 4aa33eb1cf..76ad961f13 100644 --- a/packages/config/src/config/generate.js +++ b/packages/config/src/config/generate.js @@ -8,6 +8,7 @@ export default () => ({ fallback: '200.html', crawler: true, manifest: true, + nojekyll: true, cache: { ignore: [], globbyOptions: { diff --git a/packages/config/test/__snapshots__/options.test.js.snap b/packages/config/test/__snapshots__/options.test.js.snap index 9480f671e4..940b35855c 100644 --- a/packages/config/test/__snapshots__/options.test.js.snap +++ b/packages/config/test/__snapshots__/options.test.js.snap @@ -218,6 +218,7 @@ Object { "fallback": "200.html", "interval": 0, "manifest": true, + "nojekyll": true, "routes": Array [], "staticAssets": Object { "base": "/_nuxt/static", diff --git a/packages/config/test/config/__snapshots__/index.test.js.snap b/packages/config/test/config/__snapshots__/index.test.js.snap index f9727735ef..b05a8db82a 100644 --- a/packages/config/test/config/__snapshots__/index.test.js.snap +++ b/packages/config/test/config/__snapshots__/index.test.js.snap @@ -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, diff --git a/packages/generator/src/generator.js b/packages/generator/src/generator.js index 6fe8bc61a0..7147e7713b 100644 --- a/packages/generator/src/generator.js +++ b/packages/generator/src/generator.js @@ -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/ - const nojekyllPath = path.resolve(this.distPath, '.nojekyll') - await fsExtra.writeFile(nojekyllPath, '') + 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) diff --git a/packages/generator/test/generator.init.test.js b/packages/generator/test/generator.init.test.js index 4f130e74e1..e2c977f616 100644 --- a/packages/generator/test/generator.init.test.js +++ b/packages/generator/test/generator.init.test.js @@ -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) diff --git a/packages/types/config/generate.d.ts b/packages/types/config/generate.d.ts index 72153abba2..c5e90b5057 100644 --- a/packages/types/config/generate.d.ts +++ b/packages/types/config/generate.d.ts @@ -18,6 +18,7 @@ export interface NuxtOptionsGenerate { exclude?: RegExp[] fallback?: string | boolean interval?: number + nojekyll?: boolean routes?: NuxtOptionsGenerateRoute[] | NuxtOptionsGenerateRoutesFunction | NuxtOptionsGenerateRoutesFunctionWithCallback subFolders?: boolean cache?: false | {