master-co / css

The CSS Language and Framework

Home Page:https://css.master.co

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

πŸ’– MasterCSS should look for `master.css.*` config file inside src folder (svelte)

oskar-gmerek opened this issue Β· comments

Current

Currently masterCSS and all masterCSS tools are looking for configuration file (master.css.ts) in the main folder of project. This is usual place for config files, but because we importing that config, that create a problem in vite context. Vite autodetects a root of project (which is src folder in the svelte context) and limiting importing files to this folder, deny all imports below it and throwing error:

The request url "/project/master.css.ts" is outside of Vite serving allow list.

masterCSS (and tools) looks for master.css.ts in:

/master.css.ts 
/src/

Above will fulfill a masterCSS side, but will throw error about importing file outside of allow list of Vite.

Expected

masterCSS (and tools) should looks for master.css.ts in:

/
/src/master.css.ts

This will be inside allow list of Vite, but currently is not detected by masterCSS (and tools). This is also the place from where master.css.ts is imported in the guides of integration of masterCSS with Svelte and is leading to many errors just after following a guide.

npx mcss init should also detect sveltekit, and create config file in src folder.

Probably the best for DX will be:

  • masterCSS looks for config in / and /src/
  • optional .mcss config file to change a path to master.css.* file for edge cases.

All above is in context of SvelteKit, but I believe there is more cases where above apply.

commented

Adding one more step for setting up the allow list causes fewer side effects.

Screenshot 2023-11-14 at 5 06 18β€―PM

The main reason for placing master.css.* in the root directory is that Language Service and ESLint Plugin grab configuration files from the root directory by default. Once the file location of master.css.* changes, you will have to pay more attention and manually specify the configuration of both.

Screenshot 2023-11-14 at 4 30 10β€―PM
commented

@oskar-gmerek Thx for your report! The documentation has been updated https://beta.css.master.co/docs/installation/svelte