Skip to content

Commit 2db2808

Browse files
committed
fix(react-pages): emit .nojekyll to be better compatible with gh pages
1 parent fc65011 commit 2db2808

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

packages/react-pages/src/node/index.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as path from 'path'
22
import type { PluggableList } from 'unified'
33
import type { Plugin, IndexHtmlTransformContext } from 'vite'
4+
import type { OutputPlugin } from 'rollup'
45

56
import {
67
DefaultPageStrategy,
@@ -90,6 +91,7 @@ function pluginFactory(opts: PluginConfig = {}): Plugin {
9091
rollupOptions: {
9192
output: {
9293
manualChunks: undefined,
94+
plugins: [outputPluginDisableJekyll()],
9395
},
9496
},
9597
},
@@ -341,3 +343,20 @@ function createMdxTransformPlugin(): Plugin {
341343
},
342344
}
343345
}
346+
347+
/**
348+
* Some chunk filenames may start with `_`, which will be treated as special resource by github pages. So we need to disable jekyll of github pages.
349+
* https://github.blog/2009-12-29-bypassing-jekyll-on-github-pages/
350+
*/
351+
function outputPluginDisableJekyll(): OutputPlugin {
352+
return {
353+
name: 'vite-pages-disable-jekyll',
354+
generateBundle() {
355+
this.emitFile({
356+
type: 'asset',
357+
fileName: '.nojekyll',
358+
source: '',
359+
})
360+
},
361+
}
362+
}

0 commit comments

Comments
 (0)