When I create my rescript project with vite, I change insource
property in rescript.json to false. Now rescript compiler put compiled files in lib/es6. So, if my project use react, the Main.res is compiled to Main.res.mjs in /lib/es6 folder. This file import the index.css file and when I start project, vite throw an error indicating that there is no index.css file in lib/es6. In fact, the css file is located in src folder. What do I do to configure vite and use correct path to css with insource
disabled?
Can I ask why you changed insource to false?
I had it set to false for a while when I first started rescript, and the main reason is that I never looked at the js files and viewed it as file bloat in my src directory. Especially after coming from where ts files output to a dist
directory and you almost never look at the compiled JS
File nesting in the editor has helped, but I wasn’t aware of that feature for a while
I rarely look to compiled files like @hellos3b said. I just want code that I edit in src. I think it’s just a pollution of unnecessary files in my src folder.
Now I using vscode file nesting. Anyway, I was thinking about use insource: false
and make project works.
I think there are some big issues here for sure, but ugly is better than broken imo.
If you really want "insource": false
, take a look here: https://github.com/jihchi/vite-plugin-rescript?tab=readme-ov-file#using-loader. The loader functionality of this vite plugin was made to tackle the exact issue you are having.