📌  相关文章
📜  node-sass 运行 - Shell-Bash (1)

📅  最后修改于: 2023-12-03 15:03:12.077000             🧑  作者: Mango

Node-sass

Node-sass is a library that provides binding for Node.js to LibSass, which allows to compile .scss files into .css with lightning speed.

Installation

To install Node-sass, you can use NPM like this:

npm install node-sass
Usage

You can use Node-sass in your Node.js code like this:

const sass = require('node-sass');

sass.render({
  file: 'input.scss',
  outputStyle: 'compressed'
}, function(error, result) {
  // ...
});

Here we use sass.render() function to compile Sass code. In this example, the file option specifies the input file, and the outputStyle option specifies the output style of the compiled CSS.

CLI Usage

Node-sass also provides a CLI interface for you to use from the command line. To compile a Sass file, you can use the following command:

node-sass input.scss output.css

This command will produce a CSS file called output.css from your Sass file input.scss.

Conclusion

Node-sass is a powerful library that allows you to compile your Sass files into CSS with ease. It provides both programmatic and CLI interface, making it a versatile tool for your workflow.