Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
grunt-sass
Advanced tools
The grunt-sass npm package is a Grunt plugin for compiling Sass to CSS using the node-sass library. It allows you to integrate Sass compilation into your Grunt build process, providing a streamlined way to manage your stylesheets.
Basic Sass Compilation
This feature allows you to compile a single Sass file (main.scss) into a CSS file (main.css). The configuration is set up in the Gruntfile.js, and the 'sass' task is registered as the default task.
{
"grunt.initConfig": {
"sass": {
"dist": {
"files": {
"'main.css'": "'main.scss'"
}
}
}
},
"grunt.loadNpmTasks": "'grunt-sass'",
"grunt.registerTask": "'default', ['sass']"
}
Multiple File Compilation
This feature allows you to compile multiple Sass files from a directory (sass) into a corresponding directory (css). The 'expand' option is used to enable dynamic file mapping.
{
"grunt.initConfig": {
"sass": {
"dist": {
"files": [
{
"expand": true,
"cwd": "'sass'",
"src": ["'*.scss'"],
"dest": "'css'",
"ext": "'.css'"
}
]
}
}
},
"grunt.loadNpmTasks": "'grunt-sass'",
"grunt.registerTask": "'default', ['sass']"
}
Source Maps
This feature enables the generation of source maps for the compiled CSS, which helps in debugging by mapping the CSS back to the original Sass source.
{
"grunt.initConfig": {
"sass": {
"dist": {
"options": {
"sourceMap": true
},
"files": {
"'main.css'": "'main.scss'"
}
}
}
},
"grunt.loadNpmTasks": "'grunt-sass'",
"grunt.registerTask": "'default', ['sass']"
}
node-sass is a library that provides binding for Node.js to LibSass, the C version of the popular stylesheet preprocessor, Sass. It is the underlying library used by grunt-sass for the actual compilation process. Unlike grunt-sass, node-sass is not a Grunt plugin and is used directly in Node.js scripts.
gulp-sass is a Gulp plugin for compiling Sass to CSS. It serves a similar purpose to grunt-sass but is designed to work with Gulp, another popular task runner. Gulp's streaming build system offers a different approach compared to Grunt's configuration-based system.
sass-loader is a loader for webpack that compiles Sass to CSS. It integrates seamlessly with webpack's module bundling system, making it a good choice for projects that use webpack for their build process. It offers similar functionality to grunt-sass but is tailored for webpack users.
Before filing an issue with this repository, please consider:
Asking support questions on Use Stack Overflow.
Reporting issues with the output on the Dart Sass or LibSass issue trackers, depending which implementation you're using.
Reporting installation issues on the Dart Sass or Node Sass issue trackers, depending on which implementation you're using.
$ npm install --save-dev node-sass grunt-sass
const sass = require('node-sass');
require('load-grunt-tasks')(grunt);
grunt.initConfig({
sass: {
options: {
implementation: sass,
sourceMap: true
},
dist: {
files: {
'main.css': 'main.scss'
}
}
}
});
grunt.registerTask('default', ['sass']);
You can choose whether to use Dart Sass or Node Sass by passing the module to the implementation
option. One implementation or the other must be passed.
Note that when using Dart Sass, synchronous compilation is twice as fast as asynchronous compilation by default, due to the overhead of asynchronous callbacks. To avoid this overhead, you can use the fibers
package to call asynchronous importers from the synchronous code path. To enable this, pass the Fiber
class to the fiber
option:
const Fiber = require('fibers');
const sass = require('node-sass');
require('load-grunt-tasks')(grunt);
grunt.initConfig({
sass: {
options: {
implementation: sass,
fiber: Fiber,
sourceMap: true
},
dist: {
files: {
'main.css': 'main.scss'
}
}
}
});
grunt.registerTask('default', ['sass']);
Files starting with _
are ignored to match the expected Sass partial behaviour.
See the Node Sass options, except for file
, outFile
, success
, error
.
The default value for the precision
option is 10
, so you don't have to change it when using Bootstrap.
FAQs
Compile Sass to CSS using node-sass
The npm package grunt-sass receives a total of 128,461 weekly downloads. As such, grunt-sass popularity was classified as popular.
We found that grunt-sass demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.