diff --git a/packages/vite/LICENSE.md b/packages/vite/LICENSE.md index 3cbbd7d9679694..d9c1270715bb5a 100644 --- a/packages/vite/LICENSE.md +++ b/packages/vite/LICENSE.md @@ -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 @@ -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 diff --git a/packages/vite/index.cjs b/packages/vite/index.cjs index 1c8aba26da6565..525b1b7e59f84d 100644 --- a/packages/vite/index.cjs +++ b/packages/vite/index.cjs @@ -15,7 +15,8 @@ const asyncFunctions = [ 'resolveConfig', 'optimizeDeps', 'formatPostcssSourceMap', - 'loadConfigFromFile' + 'loadConfigFromFile', + 'preprocessCSS' ] asyncFunctions.forEach((name) => { module.exports[name] = (...args) => diff --git a/packages/vite/package.json b/packages/vite/package.json index 6891d1432de591..2baf81a7b9ba45 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -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", diff --git a/packages/vite/src/node/config.ts b/packages/vite/src/node/config.ts index 654830ded4ea67..77fc70aeea48e0 100644 --- a/packages/vite/src/node/config.ts +++ b/packages/vite/src/node/config.ts @@ -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 diff --git a/packages/vite/src/node/plugins/css.ts b/packages/vite/src/node/plugins/css.ts index a582ba52404b20..5bc03bcd260153 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -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) } diff --git a/packages/vite/src/node/server/middlewares/htmlFallback.ts b/packages/vite/src/node/server/middlewares/htmlFallback.ts index 314f4ec2a63e7f..7976d24c0b09f0 100644 --- a/packages/vite/src/node/server/middlewares/htmlFallback.ts +++ b/packages/vite/src/node/server/middlewares/htmlFallback.ts @@ -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 } } ] diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 943570e2b192c1..3bdb11fc9d5ce3 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -256,7 +256,7 @@ importers: postcss: ^8.4.18 postcss-import: ^15.0.0 postcss-load-config: ^4.0.1 - postcss-modules: ^5.0.0 + postcss-modules: ^6.0.0 resolve: ^1.22.1 resolve.exports: ^1.1.0 rollup: ^2.79.1 @@ -320,7 +320,7 @@ importers: picomatch: 2.3.1 postcss-import: 15.0.0_postcss@8.4.18 postcss-load-config: 4.0.1_postcss@8.4.18 - postcss-modules: 5.0.0_postcss@8.4.18 + postcss-modules: 6.0.0_postcss@8.4.18 resolve.exports: 1.1.0 sirv: 2.0.2 source-map-js: 1.0.2 @@ -6001,10 +6001,6 @@ packages: dev: true optional: true - /icss-replace-symbols/1.1.0: - resolution: {integrity: sha512-chIaY3Vh2mh2Q3RGXttaDIzeiPvaVXJ+C4DAh/w3c37SKZ/U6PGMmuicR2EQQp9bKG8zLMCl7I+PtIoOOPp8Gg==} - dev: true - /icss-utils/5.1.0_postcss@8.4.18: resolution: {integrity: sha512-soFhflCVWLfRNOPU3iv5Z9VUdT44xFRbzjLsEzSr5AQmgqPMTHdU3PMT1Cf1ssx8fLNJDA1juftYl+PUcv3MqA==} engines: {node: ^10 || ^12 || >= 14} @@ -7514,7 +7510,7 @@ packages: ts-node: optional: true dependencies: - lilconfig: 2.0.5 + lilconfig: 2.0.6 postcss: 8.4.18 yaml: 2.1.1 dev: true @@ -7560,13 +7556,13 @@ packages: postcss: 8.4.18 dev: true - /postcss-modules/5.0.0_postcss@8.4.18: - resolution: {integrity: sha512-rGvpTDOM3//3Ysn3Xtvhzaj8ab984wKCpP02TEF559tLbUjNay3RQDpPxb7BREmfBtJm3/1WbQOZ7fSXwYLZ/w==} + /postcss-modules/6.0.0_postcss@8.4.18: + resolution: {integrity: sha512-7DGfnlyi/ju82BRzTIjWS5C4Tafmzl3R79YP/PASiocj+aa6yYphHhhKUOEoXQToId5rgyFgJ88+ccOUydjBXQ==} peerDependencies: postcss: ^8.0.0 dependencies: generic-names: 4.0.0 - icss-replace-symbols: 1.1.0 + icss-utils: 5.1.0_postcss@8.4.18 lodash.camelcase: 4.3.0 postcss: 8.4.18 postcss-modules-extract-imports: 3.0.0_postcss@8.4.18