Skip to content

Commit

Permalink
fix(remix-dev): resolve asset entry full path to support mono-repo im…
Browse files Browse the repository at this point in the history
…port of styles (#4855)
  • Loading branch information
jacob-ebey authored Dec 13, 2022
1 parent 87a0d91 commit a77f611
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .changeset/mighty-rules-drum.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"remix": patch
"@remix-run/dev": patch
---

Resolve asset entry full path to support monorepo import of styles
5 changes: 4 additions & 1 deletion packages/remix-dev/compiler/compileBrowser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ const createEsbuildConfig = (

let plugins: esbuild.Plugin[] = [
deprecatedRemixPackagePlugin(options.onWarning),
cssFilePlugin(options),
cssFilePlugin({
mode: options.mode,
rootDirectory: config.rootDirectory,
}),
urlImportsPlugin(),
mdxPlugin(config),
browserRouteModulesPlugin(config, /\?browser$/),
Expand Down
5 changes: 4 additions & 1 deletion packages/remix-dev/compiler/compilerServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ const createEsbuildConfig = (

let plugins: esbuild.Plugin[] = [
deprecatedRemixPackagePlugin(options.onWarning),
cssFilePlugin(options),
cssFilePlugin({
mode: options.mode,
rootDirectory: config.rootDirectory,
}),
urlImportsPlugin(),
mdxPlugin(config),
emptyModulesPlugin(config, /\.client(\.[jt]sx?)?$/),
Expand Down
13 changes: 11 additions & 2 deletions packages/remix-dev/compiler/plugins/cssFilePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ function normalizePathSlashes(p: string) {
*/
export function cssFilePlugin(options: {
mode: CompileOptions["mode"];
rootDirectory: string;
}): esbuild.Plugin {
return {
name: "css-file",
Expand Down Expand Up @@ -72,9 +73,17 @@ export function cssFilePlugin(options: {
let entry = Object.keys(outputs).find((out) => outputs[out].entryPoint);
invariant(entry, "entry point not found");

let normalizedEntry = normalizePathSlashes(entry);
let normalizedEntry = path.resolve(
options.rootDirectory,
normalizePathSlashes(entry)
);
let entryFile = outputFiles.find((file) => {
return normalizePathSlashes(file.path).endsWith(normalizedEntry);
return (
path.resolve(
options.rootDirectory,
normalizePathSlashes(file.path)
) === normalizedEntry
);
});

invariant(entryFile, "entry file not found");
Expand Down

0 comments on commit a77f611

Please sign in to comment.