Skip to content
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

fix: return correct value when import css file with ?url #5229

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 11 additions & 3 deletions packages/vite/src/node/plugins/css.ts
Expand Up @@ -24,7 +24,7 @@ import {
} from 'rollup'
import { dataToEsm } from '@rollup/pluginutils'
import chalk from 'chalk'
import { CLIENT_PUBLIC_PATH } from '../constants'
import { CLIENT_PUBLIC_PATH, SPECIAL_QUERY_RE } from '../constants'
import { ResolveFn, ViteDevServer } from '../'
import {
getAssetFilename,
Expand Down Expand Up @@ -161,7 +161,11 @@ export function cssPlugin(config: ResolvedConfig): Plugin {
},

async transform(raw, id) {
if (!isCSSRequest(id) || commonjsProxyRE.test(id)) {
if (
!isCSSRequest(id) ||
commonjsProxyRE.test(id) ||
SPECIAL_QUERY_RE.test(id)
) {
return
}

Expand Down Expand Up @@ -272,7 +276,11 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin {
},

async transform(css, id, ssr) {
if (!isCSSRequest(id) || commonjsProxyRE.test(id)) {
if (
!isCSSRequest(id) ||
commonjsProxyRE.test(id) ||
SPECIAL_QUERY_RE.test(id)
) {
return
}

Expand Down