Skip to main content

Run and compile sass scss file to css using node



  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


Comments

  1. This information is really useful to everyone, thank you so much for sharing valuable information with us
    Node JS Online training
    Node JS training in Hyderabad

    ReplyDelete
  2. 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.
    so keep on sharing such kind of an interesting blogs. PHP Course in Delhi

    ReplyDelete
  3. If you're trying to lose fat then you have to jump on this brand new personalized keto plan.

    To 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.

    ReplyDelete
  4. Hey, really great stuff! I didn't know much about that topic before reading this. Node Js Training And Certification In Noida

    ReplyDelete
  5. Very simple and helpful.
    Tnx

    ReplyDelete
  6. 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.
    web designing course in chennai

    ReplyDelete
  7. This comment has been removed by the author.

    ReplyDelete
  8. Thanks for sharing this wonderful information. I too learn something new from your post..
    React JS Course in Chennai

    ReplyDelete
  9. Thank you for sharing such wonderful information
    about.me/MilemarkerXFactor

    ReplyDelete
  10. I appreciated looking at your article. Very wonderful reveal. I would like to twit this on my followers. Many thanks!


    Serum VS Plasma
    Reflexive property
    How Much A Gallon Of Milk Weigh
    san jac blackboard



    ReplyDelete
  11. 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

Post a Comment

Popular posts from this blog

jQuery Datatable add date range filter

jQuery Datatable add date range filter Datatable is most useful jQuery plugin that helps to make our html tables more powerful and give powers to user to filter , search, sort, pagination etc, But Data table provides a common filter only and yes we can customize and add filter for each column, but still sometimes we need an advance filter like show results only between a date range, So today we will learn how to create a minimum and maximum date range fields and show date picker on it, and user can fill dates by selecting dates and data table will auto filter records based on it. Keep follow below steps :- I am using Bootstrap if you want to use any other framework then you can use. Create a new index.php file  and paste below code in it, i have used all required CDN like bootstrap, datatable, datepicker etc. <!DOCTYPE html> <html> <head>     <title>Datatable Date Range Filter Example</title>     <link rel="stylesheet" href="https://maxcd

How to retrieve Facebook Likes, share , comment Counts

function facebook_count($url){     // Query in FQL     $fql  = "SELECT share_count, like_count, comment_count ";     $fql .= " FROM link_stat WHERE url = '$url'";     $fqlURL = "https://api.facebook.com/method/fql.query?format=json&query=" . urlencode($fql);     // Facebook Response is in JSON     $response = file_get_contents($fqlURL);     return json_decode($response); } $fb = facebook_count('https://www.facebook.com/BahutHoGyiPadhai'); // facebook share count echo $fb[0]->share_count;  echo "like"; // facebook like count echo $fb[0]->like_count ; echo "comment"; // facebook comment count echo $fb[0]->comment_count;  ?>