#Questions
1 messages · Page 1 of 1 (latest)
npm add -D sass
and then import your scss file in your js file
for example if your HTML has a script <script src="path/to/your/index.js"></script> then in your index.js import scss with import 'path/to/your/styles.scss'. So Vite should automatically detect it and compile it to CSS on build.
I have a vanilla Vite starter template that I made for my own purposes and it uses SCSS, you can see how it's done there or you can use this template if it suits you
https://github.com/liv3rise/lvrs-vite-starter
how come yours work and mine doesent
or you mean it only works after running vite build command?
if yes thats not the solution i was looking for
i want it to readload css on every save
No, it works not only in build, but also in live development mode (npm run dev). The website will be updated as the files change.
I don't know, maybe you specified the wrong path to the scss file or something else. If you post your project, for example on GitHub, then maybe I can tell you what the problem is.
sorry im late to post this as im having my final exams
here
wait i cannot post image here
utils
---index.js
---main-image.png
---style.scss
index.html
my folder structure now in index.js
import './style.scss';
``` only thing which is written
in index.html
```html
at the bottom of body
<script src="./utils/index.js"></script>
Try adding type="module" to your <script> tag
For example
<script type="module" src="src/js/index.js"></script>
how about i put that in my package.json?
It should be there by default, as far as I remember.
Why?
why not ?
another question but its not related not vite
hows do you version your package .jdon
json
You are using import keyword. You need to specify type of module on your script.
Vite.config.js*
Vite configurations as well as Rollup configs.
Do you have any idea if it is ok to use both vite.config and rollup.config in the same project (separate files)? Any drawbacks?
