📅  最后修改于: 2023-12-03 15:03:12.077000             🧑  作者: Mango
Node-sass is a library that provides binding for Node.js to LibSass, which allows to compile .scss files into .css with lightning speed.
To install Node-sass, you can use NPM like this:
npm install node-sass
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.
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
.
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.