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 2ff094a
Showing 1 changed file with 14 additions and 8 deletions.
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 2ff094a

Please sign in to comment.