Tuesday, September 13, 2022

How to Install Sass with NPM Step by Step

 Step 1:- Make a folder


Step 2:- Need to make a pakage.json file

1. you need to check your node version and npm version


2. run npm init


The created file inside the folder


Step 3:- Now we are going to install the sass so we have the command

     npm install node-sass --save


You can check added the dependencies automatically.


Step 4:- Now we have to create the HTML file like:-

index.html


and also created the css folder and style.css file


Step 5:- Now we are going to use scss

1. Make the folder Scss and file style.scss


Step 6:- Style.css file connect to Style.scss


"compile:sass": "node-sass scss/style.scss css/style.css"

Step 7:- Goto the terminal and run the command

npm run compile:sass


Now you can check the style.css file that will show on that file.


Step 8:- Added the watch mode in compile time.


Now run the command 

npm run compile:sass -w


Step 9:- We need the compressed css so you can added the command on pakage.json file.



Step 9:- How to add multiple files in one style.css.


Commands

mkdir folder_name                  =>  Create folder
npm --version                           => Check npm version
node --version                           => Check node version
npm init                                     => Pakage.json file created
npm install node-sass --save    => Install sass added dependancies in pakage.json file
npm run compile:sass              => Compile command
npm run compile:sass -w         => Infinte Compile
npm run compile:sass -w --output-style compressed  => minify css 

No comments:

Post a Comment

If you have any problem please let me know.