diff --git a/.changeset/mighty-rules-drum.md b/.changeset/mighty-rules-drum.md new file mode 100644 index 00000000000..738c276f515 --- /dev/null +++ b/.changeset/mighty-rules-drum.md @@ -0,0 +1,6 @@ +--- +"remix": patch +"@remix-run/dev": patch +--- + +Resolve asset entry full path to support monorepo import of styles diff --git a/packages/remix-dev/compiler/compileBrowser.ts b/packages/remix-dev/compiler/compileBrowser.ts index ee1fbb29bb5..c58a9e8cf2b 100644 --- a/packages/remix-dev/compiler/compileBrowser.ts +++ b/packages/remix-dev/compiler/compileBrowser.ts @@ -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$/), diff --git a/packages/remix-dev/compiler/compilerServer.ts b/packages/remix-dev/compiler/compilerServer.ts index b0daa4b6a2a..cc6b6c3e82b 100644 --- a/packages/remix-dev/compiler/compilerServer.ts +++ b/packages/remix-dev/compiler/compilerServer.ts @@ -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?)?$/), diff --git a/packages/remix-dev/compiler/plugins/cssFilePlugin.ts b/packages/remix-dev/compiler/plugins/cssFilePlugin.ts index 9bee1a89ded..83ed1efc4cb 100644 --- a/packages/remix-dev/compiler/plugins/cssFilePlugin.ts +++ b/packages/remix-dev/compiler/plugins/cssFilePlugin.ts @@ -17,6 +17,7 @@ function normalizePathSlashes(p: string) { */ export function cssFilePlugin(options: { mode: CompileOptions["mode"]; + rootDirectory: string; }): esbuild.Plugin { return { name: "css-file", @@ -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");