Open luchillo17 opened 6 months ago
Please note this same issue about paths being broken in monorepos happens with other integrations, so far has happened with @astrojs/tailwind
, astro-icon
, and with astro-i18n
(though astro-i18n
uses the middleware instead so the issue with this one could be that I need to set its NPM scripts to run from the portfolio folder).
Just stumbled upon the same issues trying to set up a documentation site for my library. (wanted to use a subfolder for the docs, not even a full monorepo) 😑
I've also been experiencing a lot of strange issues when trying to set a custom root
path in the astro config using a monorepo setup (I also programmatically run the dev server using the dev
function).
I think I've overcome most of the issues also by using absolute instead of relative paths, but there's still a couple leaving me completely baffled:
Error: [postcss] Cannot find module './path-to-some-local-file.js'
.But if I don't include a tailwind config file, then I can start the dev server, but... well obviously tailwind styles don't get applied as the content field isn't correctly applied
Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.
[astro-island] Error hydrating /@id/C:/Users/.../src/outlet.js TypeError: Failed to fetch dynamically imported module: http://localhost:3000/@id/C:/Users/.../src/outlet.js
P.s. Sorry if it looks like I somewhat hijacked this thread, but I believe these issues might indicate a more general problem with how Astro handles custom root
paths
edit: managed to solve issue 1. which turned out to be some bizarre behaviour with an index file re-exporting a module using barrel exports. PostCSS may have been the culprit here. At this stage, I'm honestly not sure what's an Astro issue, or a Vite issue, or a monorepo setup thing - I just remember behaviour being a lot more predictable before setting the root
field (which is now necessary in my project)
To end on a more positive note: big thanks to the Astro team for the effort in exposing comprehensive APIs and a great dev experience 🙏
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
add
command relies heavily onpackage.json
location, in integrated monorepos the location of thepackage.json
is usually located 2 levels up in the folder structure, so instead of doingpnpm exec astro add astro-icon
, I'm forced to install manually.pwd
instead of relative to the Astro config file, in monorepos it is common to run commands from the root of the monorepo instead of the root of the Astro app, thus the default paths of many integrations do not resolve to the expected path/folder inside the App.root
prop in the config seems to be ignored in many (if not all) integrations, thus we're forced to provide absolute paths when customizing the integrations folders:// https://astro.build/config export default defineConfig({ root: import.meta.dirname, outDir: '../../dist/apps/portfolio', integrations: [ tailwind({ configFile: join(import.meta.dirname, './tailwind.config.mjs'), }), icon({ iconDir: join(import.meta.dirname, './src/assets/icons'), }), vue(), ], i18n: { defaultLocale: 'en', locales: ['en', 'es'], }, });