grunt-contrib-sass
Advanced tools
Comparing version 0.4.1 to 0.5.0
@@ -9,2 +9,5 @@ # Examples | ||
dist: { // Target | ||
options: { // Target options | ||
style: 'expanded' | ||
}, | ||
files: { // Dictionary of files | ||
@@ -14,15 +17,2 @@ 'main.css': 'main.scss', // 'destination': 'source' | ||
} | ||
}, | ||
dev: { // Another target | ||
options: { // Target options | ||
style: 'expanded' | ||
}, | ||
files: { | ||
'main.css': 'main.scss', | ||
'widgets.css': [ | ||
'button.scss', | ||
'tab.scss', | ||
'debug.scss' // Maybe you need one extra file in dev | ||
] | ||
} | ||
} | ||
@@ -34,3 +24,3 @@ } | ||
grunt.registerTask('default', ['jshint', 'sass']); | ||
grunt.registerTask('default', ['sass']); | ||
``` | ||
@@ -54,4 +44,9 @@ | ||
If you specify an array of `src` paths they will be concatenated. However, in most cases you would want to just `@import` them into `main.scss`. | ||
Instead of concatenating the files, just `@import` them into another `.sass` file eg. `main.scss`. | ||
## Compile multiple files | ||
You can specify multiple `destination: source` items in `files`. | ||
```javascript | ||
@@ -62,6 +57,4 @@ grunt.initConfig({ | ||
files: { | ||
'main.css': [ | ||
'reset.scss', | ||
'main.scss' | ||
] | ||
'main.css': 'main.scss', | ||
'widgets.css': 'widgets.scss' | ||
} | ||
@@ -73,5 +66,5 @@ } | ||
## Compile multiple files | ||
## Compile files in a directory | ||
You can specify multiple `destination: source` items in `files`. | ||
Instead of naming all files you want to compile, you can use the `expand` property allowing you to specify a directory. More information available in the [grunt docs](https://github.com/gruntjs/grunt/wiki/Configuring-tasks) - `Building the files object dynamically`. | ||
@@ -82,6 +75,9 @@ ```javascript | ||
dist: { | ||
files: { | ||
'main.css': 'main.scss', | ||
'widgets.css': 'widgets.scss' | ||
} | ||
files: [{ | ||
expand: true, | ||
cwd: 'styles', | ||
src: ['*.scss'], | ||
dest: '../public', | ||
ext: '.css' | ||
}] | ||
} | ||
@@ -88,0 +84,0 @@ } |
@@ -12,2 +12,5 @@ /* | ||
grunt.initConfig({ | ||
pkg: { | ||
name: 'grunt-contrib-sass' | ||
}, | ||
jshint: { | ||
@@ -43,2 +46,12 @@ options: { | ||
} | ||
}, | ||
compileBanner: { | ||
options: { | ||
banner: '/* <%= pkg.name %> banner */' | ||
}, | ||
files: { | ||
'test/tmp/scss-banner.css': ['test/fixtures/banner.scss'], | ||
'test/tmp/sass-banner.css': ['test/fixtures/banner.sass'], | ||
'test/tmp/css-banner.css': ['test/fixtures/banner.css'] | ||
} | ||
} | ||
@@ -45,0 +58,0 @@ } |
{ | ||
"name": "grunt-contrib-sass", | ||
"description": "Compile Sass to CSS", | ||
"version": "0.4.1", | ||
"version": "0.5.0", | ||
"homepage": "https://github.com/gruntjs/grunt-contrib-sass", | ||
@@ -6,0 +6,0 @@ "author": { |
@@ -154,2 +154,11 @@ # grunt-contrib-sass [![Build Status](https://travis-ci.org/gruntjs/grunt-contrib-sass.png?branch=master)](https://travis-ci.org/gruntjs/grunt-contrib-sass) | ||
#### banner | ||
Type: `String` | ||
Prepend the specified string to the output file. Useful for licensing | ||
information. | ||
### Examples | ||
@@ -163,2 +172,5 @@ | ||
dist: { // Target | ||
options: { // Target options | ||
style: 'expanded' | ||
}, | ||
files: { // Dictionary of files | ||
@@ -168,15 +180,2 @@ 'main.css': 'main.scss', // 'destination': 'source' | ||
} | ||
}, | ||
dev: { // Another target | ||
options: { // Target options | ||
style: 'expanded' | ||
}, | ||
files: { | ||
'main.css': 'main.scss', | ||
'widgets.css': [ | ||
'button.scss', | ||
'tab.scss', | ||
'debug.scss' // Maybe you need one extra file in dev | ||
] | ||
} | ||
} | ||
@@ -188,3 +187,3 @@ } | ||
grunt.registerTask('default', ['jshint', 'sass']); | ||
grunt.registerTask('default', ['sass']); | ||
``` | ||
@@ -208,4 +207,9 @@ | ||
If you specify an array of `src` paths they will be concatenated. However, in most cases you would want to just `@import` them into `main.scss`. | ||
Instead of concatenating the files, just `@import` them into another `.sass` file eg. `main.scss`. | ||
#### Compile multiple files | ||
You can specify multiple `destination: source` items in `files`. | ||
```javascript | ||
@@ -216,6 +220,4 @@ grunt.initConfig({ | ||
files: { | ||
'main.css': [ | ||
'reset.scss', | ||
'main.scss' | ||
] | ||
'main.css': 'main.scss', | ||
'widgets.css': 'widgets.scss' | ||
} | ||
@@ -227,5 +229,5 @@ } | ||
#### Compile multiple files | ||
#### Compile files in a directory | ||
You can specify multiple `destination: source` items in `files`. | ||
Instead of naming all files you want to compile, you can use the `expand` property allowing you to specify a directory. More information available in the [grunt docs](https://github.com/gruntjs/grunt/wiki/Configuring-tasks) - `Building the files object dynamically`. | ||
@@ -236,6 +238,9 @@ ```javascript | ||
dist: { | ||
files: { | ||
'main.css': 'main.scss', | ||
'widgets.css': 'widgets.scss' | ||
} | ||
files: [{ | ||
expand: true, | ||
cwd: 'styles', | ||
src: ['*.scss'], | ||
dest: '../public', | ||
ext: '.css' | ||
}] | ||
} | ||
@@ -265,2 +270,2 @@ } | ||
*This file was generated on Sat Jul 06 2013 19:55:01.* | ||
*This file was generated on Tue Jul 09 2013 13:08:22.* |
@@ -15,6 +15,26 @@ /* | ||
var bannerCallback = function (filename, banner) { | ||
var content; | ||
grunt.log.verbose.writeln('Writing CSS banner for ' + filename); | ||
content = grunt.file.read(filename); | ||
grunt.file.write(filename, banner + grunt.util.linefeed + content); | ||
}; | ||
grunt.registerMultiTask('sass', 'Compile Sass to CSS', function () { | ||
var cb = this.async(); | ||
var options = this.options(); | ||
var cb = this.async(); | ||
var passedArgs; | ||
var bundleExec; | ||
var banner; | ||
// Unset banner option if set | ||
if (options.banner) { | ||
banner = options.banner; | ||
delete options.banner; | ||
} | ||
passedArgs = dargs(options, ['bundleExec']); | ||
bundleExec = options.bundleExec; | ||
grunt.verbose.writeflags(options, 'Options'); | ||
@@ -27,9 +47,2 @@ | ||
} | ||
var args = [ | ||
src, | ||
file.dest, | ||
'--load-path', path.dirname(src) | ||
].concat(dargs(options, ['bundleExec'])); | ||
var extension = path.extname(src); | ||
var bundleExec = options.bundleExec; | ||
@@ -41,2 +54,8 @@ if (!grunt.file.exists(src)) { | ||
var args = [ | ||
src, | ||
file.dest, | ||
'--load-path', path.dirname(src) | ||
].concat(passedArgs); | ||
if (process.platform === 'win32') { | ||
@@ -53,3 +72,3 @@ args.unshift('sass.bat'); | ||
// If we're compiling scss or css files | ||
if (extension === '.css') { | ||
if (path.extname(src) === '.css') { | ||
args.push('--scss'); | ||
@@ -76,2 +95,7 @@ } | ||
// Callback to insert banner | ||
if (banner) { | ||
bannerCallback(file.dest, banner); | ||
} | ||
next(error); | ||
@@ -78,0 +102,0 @@ }); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
18112
154
263
0