-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
set Vite's publicDir
and base
options
#5601
Changes from 18 commits
6e0d0bd
e1d9529
1eebe2e
9600c7b
cc958dd
63724ef
08edcc6
3073800
8600c38
da434e9
5edd5f3
e4e9033
1f65e05
9aed215
4521b11
f1e22db
c7bc94e
0c7c581
9cbd92c
9ec256e
f01e437
ed99a2f
5b62370
ded83da
ea1bb13
c1457a2
e74f728
a382755
eee66db
14b7875
774b70c
5ef88c7
44381e4
2798f9d
e1d80c8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
'@sveltejs/kit': patch | ||
'@sveltejs/adapter-cloudflare-workers': patch | ||
'@sveltejs/adapter-cloudflare': patch | ||
'@sveltejs/adapter-netlify': patch | ||
'@sveltejs/adapter-node': patch | ||
'@sveltejs/adapter-static': patch | ||
'@sveltejs/adapter-vercel': patch | ||
--- | ||
|
||
[breaking] set Vite's `publicDir` option and change Vite's output dir |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,7 +84,7 @@ export async function prerender({ config, entries, files, log }) { | |
* @param {boolean} is_html | ||
*/ | ||
function output_filename(path, is_html) { | ||
const file = path.slice(config.paths.base.length + 1); | ||
const file = path; | ||
|
||
if (file === '') { | ||
return 'index.html'; | ||
|
@@ -109,7 +109,7 @@ export async function prerender({ config, entries, files, log }) { | |
if (seen.has(decoded)) return; | ||
seen.add(decoded); | ||
|
||
const file = decoded.slice(config.paths.base.length + 1); | ||
const file = decoded; | ||
if (files.has(file)) return; | ||
|
||
return q.add(() => visit(decoded, encoded || encodeURI(decoded), referrer)); | ||
|
@@ -121,11 +121,6 @@ export async function prerender({ config, entries, files, log }) { | |
* @param {string?} referrer | ||
*/ | ||
async function visit(decoded, encoded, referrer) { | ||
if (!decoded.startsWith(config.paths.base)) { | ||
error({ status: 404, path: decoded, referrer, referenceType: 'linked' }); | ||
return; | ||
} | ||
|
||
/** @type {Map<string, import('types').PrerenderDependency>} */ | ||
const dependencies = new Map(); | ||
|
||
|
@@ -259,10 +254,10 @@ export async function prerender({ config, entries, files, log }) { | |
for (const entry of config.prerender.entries) { | ||
if (entry === '*') { | ||
for (const entry of entries) { | ||
enqueue(null, config.paths.base + entry); // TODO can we pre-normalize these? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand what's going on with the removal of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also, not sure why you got rid of the comment. it's still a TODO There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't understand the TODO. I thought it was referring to prepending the base The base would not be needed as Vite's |
||
enqueue(null, entry); | ||
} | ||
} else { | ||
enqueue(null, config.paths.base + entry); | ||
enqueue(null, entry); | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did you remove this? no wonder the adapter-static tests are failing 😜
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Vite's
baseMiddleware
strips out thebase
path from the URLhttps://github.com/vitejs/vite/blob/dfaeb2b7dc39822bf00fc97802b758b17129c37b/packages/vite/src/node/server/index.ts#L513
https://github.com/vitejs/vite/blob/dfaeb2b7dc39822bf00fc97802b758b17129c37b/packages/vite/src/node/server/middlewares/base.ts#L17
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This means that
$page.url.pathname
is incorrect — it's missingbase