Skip to content

Commit

Permalink
chore: cherry pick v4 bug fix to v3 (#11110)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
Co-authored-by: Jason Quense <[email protected]>
Co-authored-by: sun0day <[email protected]>
  • Loading branch information
4 people authored Nov 30, 2022
1 parent bc3b5a9 commit c93a526
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 29 deletions.
29 changes: 22 additions & 7 deletions packages/vite/LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -1576,13 +1576,6 @@ Repository: https://github.com/http-party/node-http-proxy.git
---------------------------------------

## icss-replace-symbols
License: ISC
By: Glen Maddern
Repository: git+https://github.com/css-modules/icss-replace-symbols.git

---------------------------------------

## icss-utils
License: ISC
By: Glen Maddern
Expand Down Expand Up @@ -1860,6 +1853,28 @@ License: MIT
By: antonk52
Repository: https://github.com/antonk52/lilconfig

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

## loader-utils
Expand Down
3 changes: 2 additions & 1 deletion packages/vite/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ const asyncFunctions = [
'resolveConfig',
'optimizeDeps',
'formatPostcssSourceMap',
'loadConfigFromFile'
'loadConfigFromFile',
'preprocessCSS'
]
asyncFunctions.forEach((name) => {
module.exports[name] = (...args) =>
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
"picomatch": "^2.3.1",
"postcss-import": "^15.0.0",
"postcss-load-config": "^4.0.1",
"postcss-modules": "^5.0.0",
"postcss-modules": "^6.0.0",
"resolve.exports": "^1.1.0",
"sirv": "^2.0.2",
"source-map-js": "^1.0.2",
Expand Down
8 changes: 5 additions & 3 deletions packages/vite/src/node/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -529,9 +529,11 @@ export async function resolveConfig(
? path.join(path.dirname(pkgPath), `node_modules/.vite`)
: path.join(resolvedRoot, `.vite`)

const assetsFilter = config.assetsInclude
? createFilter(config.assetsInclude)
: () => false
const assetsFilter =
config.assetsInclude &&
(!(config.assetsInclude instanceof Array) || config.assetsInclude.length)
? createFilter(config.assetsInclude)
: () => false

// create an internal resolver to be used in special scenarios, e.g.
// optimizer & handling css @imports
Expand Down
4 changes: 2 additions & 2 deletions packages/vite/src/node/plugins/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -907,9 +907,9 @@ async function compileCSS(
modulesOptions.getJSON(cssFileName, _modules, outputFileName)
}
},
async resolve(id: string) {
async resolve(id: string, importer: string) {
for (const key of getCssResolversKeys(atImportResolvers)) {
const resolved = await atImportResolvers[key](id)
const resolved = await atImportResolvers[key](id, importer)
if (resolved) {
return path.resolve(resolved)
}
Expand Down
8 changes: 3 additions & 5 deletions packages/vite/src/node/server/middlewares/htmlFallback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,15 @@ export function htmlFallbackMiddleware(
rewrites: [
{
from: /\/$/,
to({ parsedUrl }: any) {
to({ parsedUrl, request }: any) {
const rewritten =
decodeURIComponent(parsedUrl.pathname) + 'index.html'

if (fs.existsSync(path.join(root, rewritten))) {
return rewritten
} else {
if (spaFallback) {
return `/index.html`
}
}

return spaFallback ? `/index.html` : request.url
}
}
]
Expand Down
16 changes: 6 additions & 10 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c93a526

Please sign in to comment.