diff --git a/.changeset/long-teachers-marry.md b/.changeset/long-teachers-marry.md new file mode 100644 index 00000000000..d64be10de06 --- /dev/null +++ b/.changeset/long-teachers-marry.md @@ -0,0 +1,5 @@ +--- +"@remix-run/dev": patch +--- + +always rewrite css-derived assets diff --git a/packages/remix-dev/compiler/plugins/cssImports.ts b/packages/remix-dev/compiler/plugins/cssImports.ts index 182007cb83d..a0d81e79866 100644 --- a/packages/remix-dev/compiler/plugins/cssImports.ts +++ b/packages/remix-dev/compiler/plugins/cssImports.ts @@ -50,7 +50,12 @@ export function cssFilePlugin(ctx: Context): esbuild.Plugin { build.onLoad({ filter: /\.css$/ }, async (args) => { let cacheKey = `css-file:${args.path}`; let { - cacheValue: { contents, watchFiles, warnings }, + cacheValue: { + contents, + watchFiles, + warnings, + outputFilesWithoutEntry, + }, } = await ctx.fileWatchCache.getOrSet(cacheKey, async () => { let fileDependencies = new Set([args.path]); let globDependencies = new Set(); @@ -166,25 +171,26 @@ export function cssFilePlugin(ctx: Context): esbuild.Plugin { } } - // write all assets - await Promise.all( - outputFilesWithoutEntry.map(({ path: filepath, contents }) => - fse.outputFile(filepath, contents) - ) - ); - return { cacheValue: { contents: entryFile.contents, // add all dependencies to watchFiles watchFiles: Array.from(fileDependencies), warnings, + outputFilesWithoutEntry, }, fileDependencies, globDependencies, }; }); + // write all assets + await Promise.all( + outputFilesWithoutEntry.map(({ path: filepath, contents }) => + fse.outputFile(filepath, contents) + ) + ); + return { contents, loader: "file",