-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Import CSS / favicons (Vite + nx) #328
Comments
Bonjour, Ton dépôt est accessible quelque part que l'on puisse regarder ? |
Oui, pardon, il est accessible ici : https://github.com/MTES-MCT/trackdechets (que l'on peut d'ailleurs ajouter à la liste des projets utilisant la lib !) |
Tu as tenté la migration sur quelle branche ? |
Branche |
I prepared a pull request but the ability to submit it is disabled on your repo. The issue is that you are in a federated Nx monorepo (with only a package.json at the root of the project). The path need to be adapted a little bit to work with you setup. You can checkout my branch here: https://github.com/garronej/trackdechets/tree/update_react-dsfr Best, |
Hello Joseph, I absolutely did try to update the paths but unfortunately it did not work out, vite continued to serve me index.html instead of my png / css. |
It seems Vite needs to be configured to allow references to the parent If you can provide a way to build and run the development server for your project, I’d be happy to configure it for you. |
I tried some of the newest NX / Vite plugin to copy the assets during the build but with no success, maybe I'm doing something wrong here : We have documentation on how to setup on a Mac here but don't bother, really. I'll find something I guess! https://github.com/MTES-MCT/trackdechets/blob/dev/CONTRIBUTING.md |
If I manage to copy assets to my output folder, I would still be left with the issue of dependencies (as in, the content of the main.css file) that would not get imported. Should I manually copy those assets too, praying you don't move them around in a future release or could there be another solution? Edit : |
For the sake of transparency here I am now : I can't use the new |
What I recomment you do is:
- <link rel="apple-touch-icon" href="./node_modules/@codegouvfr/react-dsfr/favicon/apple-touch-icon.png" />
- <link rel="icon" href="./node_modules/@codegouvfr/react-dsfr/favicon/favicon.svg" type="image/svg+xml" />
- <link rel="shortcut icon" href="./node_modules/@codegouvfr/react-dsfr/favicon/favicon.ico" type="image/x-icon" />
- <link rel="manifest" href="./node_modules/@codegouvfr/react-dsfr/favicon/manifest.webmanifest" crossorigin="use-credentials" />
- <link rel="stylesheet" href="./node_modules/@codegouvfr/react-dsfr/main.css" />
- <!-- Font preload -->
- <link rel="preload" href="./node_modules/@codegouvfr/react-dsfr/dsfr/fonts/Marianne-Regular.woff2" as="font" crossorigin="anonymous" />
- <link rel="preload" href="./node_modules/@codegouvfr/react-dsfr/dsfr/fonts/Marianne-Medium.woff2" as="font" crossorigin="anonymous" />
- <link rel="preload" href="./node_modules/@codegouvfr/react-dsfr/dsfr/fonts/Marianne-Bold.woff2" as="font" crossorigin="anonymous" /> Import the CSS in the src/main.tsx:
import "../../node_modules/@codegouvfr/react-dsfr/main.css"; Handle the favicon manually (this is trivial and won't change ever): cp -r ../node_modules/@codegouvfr/react-dsfr/favicon public
git add -A Add thoses lines to the index.html: <link rel="apple-touch-icon" href="/favicon/apple-touch-icon.png" />
<link rel="icon" href="/favicon/favicon.svg" type="image/svg+xml" />
<link rel="shortcut icon" href="/favicon/favicon.ico" type="image/x-icon" />
<link rel="manifest" href="/favicon/manifest.webmanifest" crossorigin="use-credentials" /> Don't use a vite plugin to copy the assets. They are dynamically updated based on what icons you are using. |
Thanks, that what I had settled on; I guess our tech choices won't allow direct link between index.html / node_modules. We can probably close the issue, thanks for the help provided. |
Next project you might want to give turborepo a try. It has, in my humble opignion a more sensible aproach to monorepo management. |
in Remix what I did was
then use the Remix uses Vite, so I guess it should work ? |
@kornifex OMG I'm so dumb. In import "@codegouvfr/react-dsfr/main.css"; No need to dot dot into the parent node_modules of course. @arnaudambro, thanks for the feedback, Remix adds quite a lot on top of vite though. Vanilla vite are pure SPAs |
Bonjour,
J'ai mis à jour le package
react-dsfr
et ai suivi le guide sur le setup initial ; notre projet utilise Vite donc j'ai suivi les consignes adéquates. Nous ne faisons plus que la copie des icônes avec le scriptupdate-icons
là où avant nous passions par le précédant script de copie d'assets qui faisait davantage.Le soucis se passe au niveau de l'import des favicons / CSS, vite ne les voit pas lorsque nous faisons, il redirige systématiquement l'import vers index.html
J'ai bien vu le projet de test https://github.com/garronej/react-dsfr-vite-demo mais malheureusement impossible de trouver la solution, à part de repasser par le précédent script de copie d'assets.
Peut-être y a t-il une config au niveau de vite qui est nécessaire ? Mais je ne trouve pas laquelle.
D'avance merci !
Bonne journée
Julien
The text was updated successfully, but these errors were encountered: