Today we learn how to use scss and generate css using node or Run and compile sass scss file to css using node
So please follow simple steps :-
Today we will create a project that can read scss file and generates css with it
Note: Make sure you have installed node in your system. If you want to help to install node js based on your system then check our other tutorial or check node js official website.
Now create a blank folder and open terminal(linux) or cmd(windows) and navigate to your current project folder by using cd command
Now run below command
npm init
after enter it will ask you some package info that you can fill according to you or just keep enter until it finished.
The above command will generate package.json file
Now we will install npm module that will convert our scss to css
Run below command:
npm install node-sass
So we have installed node-sass package .
Now open package.json file in your editor and add below code into it into script object
"scss": "node-sass --watch scss -o css"
After adding above line your code will be look like this
"scripts": { "test": "echo \"Error: no test specified\" && exit 1", "scss": "node-sass --watch scss -o css" }
and your package.json wil be look like this
{ "name": "scss", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "scss": "node-sass --watch scss -o css" }, "author": "", "license": "ISC", "dependencies": { "node-sass": "^4.13.0" }
}
Now create two folders scss and css and create a file styles.scss into scss folder and styles.css
After that your directory will be look like this
css
- styles.css
node_modules
scss
- styles.scss
package.json
Now run below command in your root directory
npm run scss
This command will watch our scss files changes and make generate css for it into styles.css file
Now open styles.scss file and styles.css file
Now add some scss code into styles.scss like below
$colortype : red; .clr { color: $colortype }
Files will be look like this and after saving this file you can see your css file have css code for this scss dynamically so you dont need to run command again and again , now you can write your scss code and node will generate css code automatically.
Thanks for reading. Check other tutorials also.
Related Links
How to generate css from scss
Using node js create css and scss
Npm package to generate css files for scss file
How to generate css for scss files automatically
Use watchman for scss files
Simple tutorial of scss and css
How to work with scss
Simple steps to compile and run sass files
This information is really useful to everyone, thank you so much for sharing valuable information with us
ReplyDeleteNode JS Online training
Node JS training in Hyderabad
Nice blog has been shared by you. before i read this blog i didn't have any knowledge about this but now i got some knowledge.
ReplyDeleteso keep on sharing such kind of an interesting blogs. PHP Course in Delhi
If you're trying to lose fat then you have to jump on this brand new personalized keto plan.
ReplyDeleteTo create this keto diet, certified nutritionists, fitness trainers, and top chefs united to provide keto meal plans that are useful, suitable, price-efficient, and enjoyable.
From their first launch in early 2019, hundreds of individuals have already transformed their body and health with the benefits a certified keto plan can give.
Speaking of benefits: in this link, you'll discover eight scientifically-certified ones offered by the keto plan.
Hey, really great stuff! I didn't know much about that topic before reading this. Node Js Training And Certification In Noida
ReplyDeleteVery simple and helpful.
ReplyDeleteTnx
Thank you for your post, I look for such article along time, today i find it finally. this post give me lots of advise it is very useful for me.
ReplyDeleteweb designing course in chennai
This comment has been removed by the author.
ReplyDeleteThanks for sharing this wonderful information. I too learn something new from your post..
ReplyDeleteReact JS Course in Chennai
Thank you for sharing such wonderful information
ReplyDeleteabout.me/MilemarkerXFactor
I appreciated looking at your article. Very wonderful reveal. I would like to twit this on my followers. Many thanks!
ReplyDeleteSerum VS Plasma
Reflexive property
How Much A Gallon Of Milk Weigh
san jac blackboard
An amazing web journal I visit this blog, it's unbelievably wonderful.
ReplyDelete7 Reasons Why You Should Use React Native For Mobile Applications?
Xamarin vs React Native: How To Choose Best Framework For Cross-Platform App Development
Flutter vs React Native – Which to Choose In 2022
List of New React Hooks Introduced in React 18
If you're getting the "invalid card" message, you should verify the pin number on your card and your card to ensure that you have entered the correct details.macy's gift card balance
ReplyDelete