Skip to content

Commit

Permalink
fix(dev): always rewrite css-derived assets
Browse files Browse the repository at this point in the history
  • Loading branch information
pcattori committed Jul 14, 2023
1 parent 76d3eb9 commit 4618bbc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/long-teachers-marry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@remix-run/dev": patch
---

always rewrite css-derived assets
22 changes: 14 additions & 8 deletions packages/remix-dev/compiler/plugins/cssImports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>();
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 4618bbc

Please sign in to comment.