mirror of
https://github.com/vitejs/vite.git
synced 2024-11-21 22:59:10 +00:00
chore: patch sirv/build.js as well (#12061)
Co-authored-by: sapphi-red <green@sapphi.red>
This commit is contained in:
parent
f3ab3b0266
commit
b066d45c28
@ -1,3 +1,33 @@
|
||||
diff --git a/build.js b/build.js
|
||||
index b046ee138b1f9047c70beaeea7279d3476d7e8cd..574ce1410a1344a4db292803d05c303f8c03767c 100644
|
||||
--- a/build.js
|
||||
+++ b/build.js
|
||||
@@ -35,7 +35,7 @@ function viaCache(cache, uri, extns) {
|
||||
}
|
||||
}
|
||||
|
||||
-function viaLocal(dir, isEtag, uri, extns) {
|
||||
+function viaLocal(dir, isEtag, uri, extns, shouldServe) {
|
||||
let i=0, arr=toAssume(uri, extns);
|
||||
let abs, stats, name, headers;
|
||||
for (; i < arr.length; i++) {
|
||||
@@ -43,6 +43,7 @@ function viaLocal(dir, isEtag, uri, extns) {
|
||||
if (abs.startsWith(dir) && fs.existsSync(abs)) {
|
||||
stats = fs.statSync(abs);
|
||||
if (stats.isDirectory()) continue;
|
||||
+ if (shouldServe && !shouldServe(abs)) continue;
|
||||
headers = toHeaders(name, stats, isEtag);
|
||||
headers['Cache-Control'] = isEtag ? 'no-cache' : 'no-store';
|
||||
return { abs, stats, headers };
|
||||
@@ -172,7 +173,7 @@ module.exports = function (dir, opts={}) {
|
||||
catch (err) { /* malform uri */ }
|
||||
}
|
||||
|
||||
- let data = lookup(pathname, extns) || isSPA && !isMatch(pathname, ignores) && lookup(fallback, extns);
|
||||
+ let data = lookup(pathname, extns, opts.shouldServe) || isSPA && !isMatch(pathname, ignores) && lookup(fallback, extns, opts.shouldServe);
|
||||
if (!data) return next ? next() : isNotFound(req, res);
|
||||
|
||||
if (isEtag && req.headers['if-none-match'] === data.headers['ETag']) {
|
||||
diff --git a/build.mjs b/build.mjs
|
||||
index fe01068d0dd3f788a0978802db1747dd83c5825e..fb099c38cc2cbd59300471e7307625e2fc127f0c 100644
|
||||
--- a/build.mjs
|
||||
|
@ -10,7 +10,7 @@ patchedDependencies:
|
||||
hash: 6vdpvodnfhahap67xag6diqqtu
|
||||
path: patches/dotenv-expand@9.0.0.patch
|
||||
sirv@2.0.2:
|
||||
hash: w6q35pvk7bmykgqf2hieut43iq
|
||||
hash: hmoqtj4vy3i7wnpchga2a2mu3y
|
||||
path: patches/sirv@2.0.2.patch
|
||||
|
||||
importers:
|
||||
@ -283,7 +283,7 @@ importers:
|
||||
postcss-modules: 6.0.0_postcss@8.4.21
|
||||
resolve.exports: 2.0.0
|
||||
rollup-plugin-license: 3.0.1_rollup@3.10.0
|
||||
sirv: 2.0.2_w6q35pvk7bmykgqf2hieut43iq
|
||||
sirv: 2.0.2_hmoqtj4vy3i7wnpchga2a2mu3y
|
||||
source-map-js: 1.0.2
|
||||
source-map-support: 0.5.21
|
||||
strip-ansi: 7.0.1
|
||||
@ -306,7 +306,7 @@ importers:
|
||||
css-color-names: 1.0.1
|
||||
kill-port: 1.6.1
|
||||
node-fetch: 3.3.0
|
||||
sirv: 2.0.2_w6q35pvk7bmykgqf2hieut43iq
|
||||
sirv: 2.0.2_hmoqtj4vy3i7wnpchga2a2mu3y
|
||||
|
||||
playground/alias:
|
||||
specifiers:
|
||||
@ -8637,7 +8637,7 @@ packages:
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
|
||||
/sirv/2.0.2_w6q35pvk7bmykgqf2hieut43iq:
|
||||
/sirv/2.0.2_hmoqtj4vy3i7wnpchga2a2mu3y:
|
||||
resolution: {integrity: sha512-4Qog6aE29nIjAOKe/wowFTxOdmbEZKb+3tsLljaBRzJwtqto0BChD2zzH0LhgCSXiI+V7X+Y45v14wBZQ1TK3w==}
|
||||
engines: {node: '>= 10'}
|
||||
dependencies:
|
||||
|
Loading…
Reference in New Issue
Block a user