Skip to content

Commit c93a526

Browse files
bluwysun0dayjquensesun0day
authoredNov 30, 2022
chore: cherry pick v4 bug fix to v3 (#11110)
* fix(config): exclude config.assetsInclude empty array (#10941) fixes #10926 * feat(css): upgrade postcss-modules (#10987) * fix(mpa): support mpa fallback (#10985) fixes #10966 * fix: export preprocessCSS in CJS (#11067) * chore: update license Co-authored-by: sun0day <sun_day500@163.com> Co-authored-by: Jason Quense <monastic.panic@gmail.com> Co-authored-by: sun0day <ivan.xu@applovin.com>
1 parent bc3b5a9 commit c93a526

File tree

7 files changed

+41
-29
lines changed

7 files changed

+41
-29
lines changed
 

‎packages/vite/LICENSE.md

+22-7
Original file line numberDiff line numberDiff line change
@@ -1576,13 +1576,6 @@ Repository: https://github.com/http-party/node-http-proxy.git
15761576
15771577
---------------------------------------
15781578

1579-
## icss-replace-symbols
1580-
License: ISC
1581-
By: Glen Maddern
1582-
Repository: git+https://github.com/css-modules/icss-replace-symbols.git
1583-
1584-
---------------------------------------
1585-
15861579
## icss-utils
15871580
License: ISC
15881581
By: Glen Maddern
@@ -1860,6 +1853,28 @@ License: MIT
18601853
By: antonk52
18611854
Repository: https://github.com/antonk52/lilconfig
18621855

1856+
> MIT License
1857+
>
1858+
> Copyright (c) 2022 Anton Kastritskiy
1859+
>
1860+
> Permission is hereby granted, free of charge, to any person obtaining a copy
1861+
> of this software and associated documentation files (the "Software"), to deal
1862+
> in the Software without restriction, including without limitation the rights
1863+
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1864+
> copies of the Software, and to permit persons to whom the Software is
1865+
> furnished to do so, subject to the following conditions:
1866+
>
1867+
> The above copyright notice and this permission notice shall be included in all
1868+
> copies or substantial portions of the Software.
1869+
>
1870+
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1871+
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1872+
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1873+
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1874+
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1875+
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1876+
> SOFTWARE.
1877+
18631878
---------------------------------------
18641879

18651880
## loader-utils

‎packages/vite/index.cjs

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ const asyncFunctions = [
1515
'resolveConfig',
1616
'optimizeDeps',
1717
'formatPostcssSourceMap',
18-
'loadConfigFromFile'
18+
'loadConfigFromFile',
19+
'preprocessCSS'
1920
]
2021
asyncFunctions.forEach((name) => {
2122
module.exports[name] = (...args) =>

‎packages/vite/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109
"picomatch": "^2.3.1",
110110
"postcss-import": "^15.0.0",
111111
"postcss-load-config": "^4.0.1",
112-
"postcss-modules": "^5.0.0",
112+
"postcss-modules": "^6.0.0",
113113
"resolve.exports": "^1.1.0",
114114
"sirv": "^2.0.2",
115115
"source-map-js": "^1.0.2",

‎packages/vite/src/node/config.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -529,9 +529,11 @@ export async function resolveConfig(
529529
? path.join(path.dirname(pkgPath), `node_modules/.vite`)
530530
: path.join(resolvedRoot, `.vite`)
531531

532-
const assetsFilter = config.assetsInclude
533-
? createFilter(config.assetsInclude)
534-
: () => false
532+
const assetsFilter =
533+
config.assetsInclude &&
534+
(!(config.assetsInclude instanceof Array) || config.assetsInclude.length)
535+
? createFilter(config.assetsInclude)
536+
: () => false
535537

536538
// create an internal resolver to be used in special scenarios, e.g.
537539
// optimizer & handling css @imports

‎packages/vite/src/node/plugins/css.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -907,9 +907,9 @@ async function compileCSS(
907907
modulesOptions.getJSON(cssFileName, _modules, outputFileName)
908908
}
909909
},
910-
async resolve(id: string) {
910+
async resolve(id: string, importer: string) {
911911
for (const key of getCssResolversKeys(atImportResolvers)) {
912-
const resolved = await atImportResolvers[key](id)
912+
const resolved = await atImportResolvers[key](id, importer)
913913
if (resolved) {
914914
return path.resolve(resolved)
915915
}

‎packages/vite/src/node/server/middlewares/htmlFallback.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,15 @@ export function htmlFallbackMiddleware(
1414
rewrites: [
1515
{
1616
from: /\/$/,
17-
to({ parsedUrl }: any) {
17+
to({ parsedUrl, request }: any) {
1818
const rewritten =
1919
decodeURIComponent(parsedUrl.pathname) + 'index.html'
2020

2121
if (fs.existsSync(path.join(root, rewritten))) {
2222
return rewritten
23-
} else {
24-
if (spaFallback) {
25-
return `/index.html`
26-
}
2723
}
24+
25+
return spaFallback ? `/index.html` : request.url
2826
}
2927
}
3028
]

‎pnpm-lock.yaml

+6-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
Please sign in to comment.