Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/vite/src/node/plugins/importAnalysis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
CLIENT_PUBLIC_PATH,
DEP_VERSION_RE,
FS_PREFIX,
SPECIAL_QUERY_RE,
} from '../constants'
import {
debugHmr,
Expand Down Expand Up @@ -743,7 +744,8 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin {
// update the module graph for HMR analysis.
// node CSS imports does its own graph update in the css-analysis plugin so we
// only handle js graph updates here.
if (!isCSSRequest(importer)) {
// note that we want to handle .css?raw and .css?url here
if (!isCSSRequest(importer) || SPECIAL_QUERY_RE.test(importer)) {
// attached by pluginContainer.addWatchFile
const pluginImports = (this as any)._addedImports as
| Set<string>
Expand Down
10 changes: 10 additions & 0 deletions playground/css/__tests__/css.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,16 @@ test('?raw', async () => {
expect(await rawImportCss.textContent()).toBe(
readFileSync(require.resolve('../raw-imported.css'), 'utf-8'),
)

if (!isBuild) {
editFile('raw-imported.css', (code) =>
code.replace('color: yellow', 'color: blue'),
)
await untilUpdated(
() => page.textContent('.raw-imported-css'),
'color: blue',
)
}
})

test('import css in less', async () => {
Expand Down