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', fallback: '200.html',
crawler: true, crawler: true,
manifest: true, manifest: true,
nojekyll: true,
cache: { cache: {
ignore: [], ignore: [],
globbyOptions: { globbyOptions: {

View File

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

View File

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

View File

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

View File

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

View File

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