Compare commits

...

138 commits
2.x ... master

Author SHA1 Message Date
selfisekai 06bd869e5d release 4.2.0 2020-11-06 14:46:25 +01:00
selfisekai 968c903c9f remove engine compatibility entry 2020-11-06 14:01:35 +01:00
selfisekai c256bbe4dd add gitlab ci 2020-11-06 13:59:31 +01:00
selfisekai b7569dd457 typescript typedefs 2020-11-06 12:24:32 +01:00
selfisekai 148502cd95 made dart sass default 2020-11-06 12:24:25 +01:00
selfisekai bcf64926b8 this is a fork 🔥 2020-11-05 23:40:12 +01:00
xzyfer 8d6ac29097 Update changelog 2020-04-23 20:26:33 +10:00
xzyfer 43c05476ed 4.1.0 2020-04-23 20:19:16 +10:00
Ken Newman ebe3ec6b5e
Set appropriate file stat times (#763)
* Set appropriate file stat times

Since we are creating the destination file, it's our responsibility to set the file stat times.

* fix code style
2020-04-23 13:12:23 +10:00
Christophe Coevoet 7ab018e367 Migrate to the lodash package
The modularized lodash packages are unmaintained since 2 years, lagging a lot
behind the main lodash package. Partial imports of lodash are the preferred
way.
2019-08-05 21:13:31 +10:00
xzyfer fa670c64b2 4.0.2 2018-10-16 19:00:47 +11:00
xzyfer fefa00e707 Revert package.json version bump 2018-10-16 19:00:43 +11:00
Natalie Weizenbaum 98254d2d0d Fix README typos 2018-10-16 17:57:46 +10:00
Natalie Weizenbaum 8a14419856 Continue loading Node Sass by default
This documents the option to use Dart Sass, and encourages users to
explicitly choose their implementation, but it doesn't change the
existing behavior.
2018-10-16 17:57:46 +10:00
Natalie Weizenbaum 938afbe3dc Add a note about synchronous versus asynchronous speed 2018-10-16 17:57:46 +10:00
Natalie Weizenbaum 7cc2db1168 Make this package implementation-agnostic
Rather than always loading Node Sass, this now requires users to pass
in either Dart Sass or Node Sass to the require() call.

Closes #672
2018-10-16 17:57:46 +10:00
Jacob Francis Powers 643f73b64a Add documentation for synchronous code options
It's not clearly documented how to add options to sass.sync, and this is implemented inconsistently across other code infrastructures, so it's not safe to assume whether it's `sass(options).sync()` or `sass.sync(options)` please accept the pull request if the proposed documentation is correct, or otherwise accept it anyways and provide a follow up merge as an update fix.
2018-05-23 09:39:48 +02:00
xzyfer 0b3c7e7b83 4.0.1 2018-04-08 13:11:09 +10:00
Michael Mifsud daca90dd95
Merge pull request #681 from DKvistgaard/master
Declaring logError as function instead of arrow function.
2018-04-08 13:10:17 +10:00
Daniel Kvistgaard 71471c2d2c Declaring logError as function instead of arrow function. 2018-04-08 13:05:50 +10:00
xzyfer 450a7b8b4f 4.0.0 2018-04-05 21:10:27 +10:00
Michael Mifsud e9b1fe8d42
Fix node versions in appveyor.yml 2018-04-05 21:08:06 +10:00
Michael Mifsud 44be409bd9
Merge pull request #667 from dlmanning/next
Drop support for non-Active LTS and Current releases
2018-04-05 16:02:00 +10:00
xzyfer 7656eff297 Adopt airbnb eslint preset 2018-03-24 12:55:37 +11:00
xzyfer 12931694be Bump autoprefixer@^8.1.0, gulp-postcss@^7.0.1 2018-03-24 12:55:37 +11:00
xzyfer 9fa817b8c4 Bump gulp-sourcemaps@^2.6.4 2018-03-24 12:55:37 +11:00
xzyfer a0576953ad Bump should@^13.2.1 2018-03-24 12:55:37 +11:00
xzyfer 549d7ba9aa Bump mocha@^5.0.4 2018-03-24 12:55:37 +11:00
Charles Samborski e61535250e Drop dependency on deprecated gulp-util
Closes dlmanning/gulp-sass#646
2018-03-24 12:55:35 +11:00
xzyfer 9a8a8797ca Drop support for non-active lts and current release
Closes #649
2018-03-24 12:55:07 +11:00
Michael Mifsud 04fb925e40
3.2.1 2018-03-24 11:33:28 +11:00
Michael Mifsud ff8b225245
Bump node-sass@^4.8.3
Make the latest stable node-sass the minimum.
2018-03-24 11:33:10 +11:00
xzyfer 44256d3315 3.2.0 2018-03-12 14:22:37 +11:00
xzyfer c0a2973846 Test on all supported Windows platforms 2018-03-11 21:18:33 +11:00
xzyfer 19685965ff Update CHANGELOG
Fixes #588
2018-03-11 21:15:38 +11:00
xzyfer 5fc1e30fbe Bump node-sass@^4.8.0
Force update to LibSass 3.5.0.
2018-03-11 21:08:17 +11:00
Paul Hawxby cc4ed2fc34 Unit tests now work on windows
Closes #620
2018-03-11 16:37:23 +11:00
xzyfer e45e200633 Simplifiy appveyor config 2018-03-11 15:24:02 +11:00
xzyfer 6dadb97b95 Add Appveyor for Windows CI 2018-03-11 15:05:12 +11:00
Yusril Herlian Syah 2b090fe07d Add whitespace 2018-01-30 09:24:06 +11:00
xzyfer 25d37e799a 3.1.0 2017-01-09 19:17:52 +11:00
Michael Mifsud 3709a76337 Bump node-sass@^4.2.0
node-sass@4.2.0 significantly improves memory usage.

Fixes #575
2017-01-09 19:16:36 +11:00
xzyfer 0d2a2bffb6 3.0.0 2016-12-11 00:54:09 +11:00
xzyfer 251fbc836c Bump node-sass@v4.0.0
Get the latest LibSass.

https://github.com/sass/node-sass/releases/tag/v4.0.0
2016-12-11 00:53:56 +11:00
xzyfer 218560fc06 2.3.2 2016-06-15 20:56:34 +10:00
Michael Mifsud 568b13bbc1 Merge pull request #509 from xzyfer/fix/option-leakage
Prevent options leaking between compilations
2016-06-15 20:56:11 +10:00
xzyfer 035b759f51 Prevent options leaking between compilations
Currently options are leaking between compilation runs. This is most
evident when using an array of importers. The array is shallow copied
internally, and the children of that array are wrapped by Node Sass.

When the next file is compiled the options are shallow copied once
again however this time the importer array contains the wrapped
importers not the original ones.

Instead of shallow copying with `Object.assign` this patch does a
full deep clone. Node Sass should also do this to prevent mutating
the options being passed in.

Related sass/node-sass#1168
Fixes #467 (probably)
2016-06-15 20:54:04 +10:00
Michael Mifsud 05f4cdf10f Merge pull request #490 from xzyfer/feat/bump-some-deps
Bump some deps
2016-05-04 01:49:33 +10:00
xzyfer ef6fa52e99 Bump some deps
For reasons
2016-05-04 01:47:16 +10:00
xzyfer cfee756077 Allow the buggy node-sass@3.4.2 to be used 2016-04-22 09:02:11 +10:00
xzyfer ebb66e8455 v2.3.1 2016-04-22 09:01:46 +10:00
Michael Mifsud f049f688a1 Merge pull request #474 from xzyfer/feat/fix-include-paths
Restore includePaths logic
2016-04-22 08:52:13 +10:00
xzyfer 1d72ed3fc1 Restore includePaths logic
I believe this was mistakenly removed in #353.

@eoneill can you shed some light on why you removed this? It has
caused issues for users.

Fixes #469
Fixes #473
2016-04-21 23:49:31 +10:00
Michael Mifsud 439035f380 Merge pull request #468 from xzyfer/feat/node-sass/3.5.0
Update to node-sass@3.5.1 stable
2016-04-21 11:31:41 +10:00
xzyfer ae029bf425 Update to node-sass@3.5.1 stable 2016-04-21 10:50:18 +10:00
Michael Mifsud 74d6a1a6ab Merge pull request #353 from eoneill/master
Add the .file property to options before handing off to node-sass
2016-03-16 16:06:46 +11:00
Michael Mifsud fa90705182 Merge pull request #441 from cheapsteak/patch-2
Update Readme to clarify that `data` is not passed to node-sass
2016-02-15 21:15:32 +11:00
Chang Wang 206829038c Update Readme to clarify that data is not passed to node-sass 2016-02-15 05:12:53 -05:00
Michael Mifsud 06dd57a797 Merge pull request #437 from xzyfer/feat/node-sass-beta
Prepare 2.3.0-beta.1 with node-sass@3.5.0-beta.1
2016-02-04 23:07:01 +11:00
xzyfer 9609cfe4d2 Prepare 2.3.0-beta.1 with node-sass@3.5.0-beta.1 2016-02-04 23:04:02 +11:00
Michael Mifsud 67874cb608 Merge pull request #436 from dlmanning/fix/sourcemap-tests
Fix failing sourcemaps tests
2016-02-04 23:00:33 +11:00
xzyfer 3150325f32 Fix failing sourcemaps tests
It looks like a dependency has caused some tests to start failing.
Sourcemaps are not a documented API so this is not a breaking
change.
2016-02-04 22:56:41 +11:00
xzyfer 1888f3561f 2.2.0 2016-02-04 22:35:25 +11:00
Michael Mifsud cc1bca67b1 Merge pull request #408 from Keats/master
Return streams + handle errors everytime in README
2015-12-22 11:08:06 +11:00
Vincent Prouillet 52fba693e0 Merge pull request #420 from jlgeering/error-msg-unformatted
preserve the original error message for notification(s) support
2015-12-21 10:53:18 +00:00
Vincent Prouillet 847a2d3e39 Merge pull request #417 from ajschlosser/master
add relativePath property to error object for notification(s) support
2015-12-21 10:52:14 +00:00
Jean-Luc Geering 3075a845c6 preserve the original error message 2015-12-21 09:45:33 +01:00
Aaron Schloser 5e8af62356 add relativePath assertion to sync test 2015-12-18 10:38:44 -08:00
Aaron Schloser b3fe81f86a add relativePath property to error object in order to play nicely with gulp-notify 2015-12-18 10:35:52 -08:00
xzyfer d62227fb9d 2.1.1 2015-12-10 23:56:08 +11:00
Eugene ONeill cc31400b55 fix sourcemap transform 2015-12-03 16:14:27 -08:00
Eugene ONeill 058b42c80a remove unnecessary includePaths adjusts now that we're setting file property correctly 2015-12-03 16:14:27 -08:00
Eugene ONeill 31a3218ae6 add the .file property to options before handing off to node-sass 2015-12-03 16:14:27 -08:00
Vincent Prouillet 9438bf2c82 Use new travis infrastructure 2015-12-02 17:44:44 +00:00
Vincent Prouillet bb90ad76ee Merge pull request #407 from joevbruno/filename-patch
Fixed sourcemaps filename issue ('stdin')
2015-12-02 17:43:18 +00:00
Joe Bruno 4e51591c96 Forgot a comma ... 2015-12-02 12:36:37 -05:00
Joe Bruno 19f54ce753 changed var srcs to filteredSources + Travis Fix
I changed var srcs to filteredSources to be more semantic and closer to the existing formatting. I moved the var declaration to the top level in an attempt to comply with the established coding standards.
2015-12-02 12:30:41 -05:00
Joe Bruno 9c042f3cc2 Remove the commented code and l95 2015-12-02 12:13:53 -05:00
Vincent Prouillet e4f84b0f64 Return streams + handle errors everytime in README 2015-12-02 16:50:55 +00:00
Joe Bruno 00963bc41f Fixed sourcemaps filename issue ('stdin')
Fixed the issue where sourcemaps were not displaying the correct filename, but were instead displaying 'stdin'
2015-12-01 13:15:29 -05:00
Michael Mifsud 5787925539 Merge pull request #375 from xzyfer/release/3.1.0
2.1.0
2015-10-28 01:10:17 +11:00
xzyfer 4667e0bf8c 2.1.0 2015-10-28 01:07:24 +11:00
Michael Mifsud d7ca6a45e8 Merge pull request #376 from xzyfer/feat/update-deps
Update PostCSS deps the latest versions that support 0.10
2015-10-26 02:05:36 +11:00
xzyfer a8f39336c8 Update PostCSS deps the latest versions that support 0.10
PostCSS >= 6.0.0 has dropped support for Node 0.10. Whether we
want to follow suit is beyond my pay grade here :)
2015-10-26 02:02:47 +11:00
Michael Mifsud 66083d7d9c Merge pull request #360 from xzyfer/feat/update-deps
Update npm dependencies
2015-10-26 01:57:05 +11:00
xzyfer ebd4892b52 Update dependencies
Some of our dependencies were at least a major version our of date.
2015-10-26 01:54:23 +11:00
xzyfer 1f11c8d066 Update dev dependencies
Some of our dev dependencies are at least a major version behind.
This require update required updating our .eslintrc config because
some of the rules we used have been removed.
2015-10-26 01:54:22 +11:00
Michael Mifsud 33a8a4fee9 Merge pull request #358 from xzyfer/fix/empty-file
An empty Sass file should produce an empty CSS file
2015-10-26 01:34:12 +11:00
Michael Mifsud 623eebc2c7 Merge pull request #359 from xzyfer/fix/dirty-tests
Test runner should clean up after itself
2015-10-26 01:32:43 +11:00
Michael Mifsud 830e7f813c Merge pull request #374 from xzyfer/feat/node-sass-3-4
Node Sass 3.4.0
2015-10-26 01:23:19 +11:00
xzyfer 57f8c6d7ea Use LibSass' pre-formatted error messages 2015-10-26 01:20:58 +11:00
xzyfer 5246a9481d Bump node-sass@^3.4.0 2015-10-26 00:41:59 +11:00
Michael Mifsud 07a93a8184 Merge pull request #366 from coryhouse/patch-1
Typo fix
2015-10-13 11:00:00 +11:00
Cory House 722ca50d8b Typo fix 2015-10-12 12:03:12 -05:00
xzyfer 3b30b8a444 Test runner should clean up after itself
We don't remove generated files between tests which results in
false positives when asserting if a file was created. This was
noticed when creating the test cases for #358
2015-10-05 15:14:57 +11:00
xzyfer f8a75e6adf An empty Sass file should produce an empty CSS file
Currently if the input file is blank we bail out early, returning
the input file object. This causes gulp to simply copy the input
Sass file. We instead need to rewrite the file extension to .css.
Fixes #352
2015-10-05 15:09:26 +11:00
xzyfer 04f9a9318c 2.1.0-beta 2015-09-21 22:13:26 +10:00
xzyfer 55d4d51d35 Update CHANGELOG 2015-09-21 22:13:25 +10:00
Michael Mifsud 839c315372 Merge pull request #344 from xzyfer/feat/node-sass-34-beta
Use node-sass@3.4.0-beta
2015-09-21 22:09:24 +10:00
xzyfer 16d4efed16 Use node-sass@3.4.0-beta 2015-09-21 22:05:47 +10:00
Sam Richard 64d93e6945 Merge pull request #320 from martinoconnor/master
Modify sourcemap paths of imported files
2015-09-19 06:45:41 -04:00
Martin O'Connor 77e66a795a Use path.dirname for enhanced readability 2015-07-30 22:26:15 -04:00
Martin O'Connor 936518d258 Merge remote-tracking branch 'dlmanning/master' 2015-07-30 15:01:36 -04:00
Martin O'Connor fb26b3a259 Update file processing to a cross platform solution 2015-07-30 14:32:41 -04:00
Martin O'Connor 9cb5f1cb5c Modify sourcemap paths of imported files relative to file.base instead of relative to file, if a different base is specified. 2015-07-30 12:33:15 -04:00
Sam Richard 8bfcb19b45 Update CHANGELOG.md 2015-07-30 11:11:04 -04:00
Sam Richard 7604019895 Update README.md 2015-07-22 09:27:34 -04:00
Sam Richard d7a711d21c Update README.md 2015-07-22 09:27:21 -04:00
Sam Richard 8f5e91f442 2.0.4 2015-07-15 11:03:12 -07:00
Sam Richard 2a4f945da9 Add test for globbed files
Resolves #282

Resolves #278
2015-07-15 11:00:56 -07:00
Sam Richard 2b0f446b9d Merge pull request #314 from TrySound/fix-sourcemaps
Fixed sourcemaps with different file.base
2015-07-14 05:11:38 -07:00
Bogdan Chadkin 38e3c361f1 Fixed sourcemaps with different file.base 2015-07-12 22:32:17 +03:00
Sam Richard a94f80de4e 2.0.3 2015-06-27 12:40:24 -05:00
Sam Richard 6e085bf215 Update CHANGELOG 2015-06-27 12:40:15 -05:00
Sam Richard 1604fe745d 🐛 Fix empty partials copied to CSS folder
Resolves #306
2015-06-27 12:39:28 -05:00
Sam Richard d1930b8cba 2.0.2 2015-06-25 09:39:44 -05:00
Sam Richard 612f2e2b5c Update CHANGELOG 2015-06-25 09:39:11 -05:00
Sam Richard 273e0a33f8 Merge pull request #293 from mariusc23/master
Fix gulp watch stopping on error.
2015-06-25 09:36:35 -05:00
Vincent Prouillet e8ed3bdc63 Merge pull request #294 from aj0strow/fix-empty-file
check contents length for empty file
2015-06-19 04:54:21 +01:00
AJ Ostrow 7f6605e433 check contents length for empty file 2015-06-10 17:45:12 -04:00
Marius Craciunoiu 061fce9878 Use gutil.PluginError instead of log. 2015-06-09 17:34:58 -04:00
Marius Craciunoiu de7414b630 Fix gulp watch stopping on error. 2015-06-09 16:46:29 -04:00
Vincent Prouillet 1f54efec9d Add example in README on how to pass node-sass options 2015-06-09 11:01:04 +01:00
Sam Richard 4045aaab2d 📝 Update Changelog
And version bump
2015-05-13 07:16:13 -04:00
Sam Richard 0774a7693b Merge pull request #273 from unic/master
Error handling: Throw complete sass error but extend message
2015-05-13 07:09:54 -04:00
Thomas Jaggi 62af7d477a Error handling: Throw complete sass error but extend message 2015-05-12 18:48:07 +02:00
Thomas Jaggi fc8695a4ca Merge remote-tracking branch 'upstream/master' 2015-05-12 17:59:42 +02:00
Sam Richard 9be18f1a85 Merge pull request #271 from sup3rman/sup3rman
Unshift instead of push current file's path onto includePaths.
2015-05-12 10:50:06 -04:00
Linus Miller 9407865e27 Unshift instead of push current files path onto includePaths. 2015-05-12 13:31:04 +02:00
Sam Richard 0b84f2a518 Add link to Common Issues
Also updated for inclusion of OS/Node debugging information
2015-05-10 08:52:08 -04:00
Sam Richard 1a2ebe04d8 Update CHANGELOG.md 2015-05-10 08:49:19 -04:00
Vincent Prouillet a09fa6bb1a Merge pull request #266 from Snugug/feature/better-error-testing
Add file name and line:column to error test
2015-05-10 13:30:10 +01:00
Sam Richard cff205b013 Add file name and line:column to error test 2015-05-10 05:27:08 -04:00
Sam Richard 0976aa42af Update README.md 2015-05-09 11:06:31 -04:00
Sam Richard fd539150d7 Merge pull request #262 from unic/master
Fix issue with sourcemaps when using gulp-sourcemaps and autoprefixer
2015-05-09 11:02:48 -04:00
Thomas Jaggi bdb05ca910 Add test case with gulp-sourcemaps and autoprefixer 2015-05-09 12:12:13 +02:00
Sam Richard 04be1e4600 Add NPM version badge 2015-05-07 07:24:05 -04:00
Vincent Prouillet ee039186f0 Merge pull request #254 from dlmanning/2.x
Merge 2.x into Master
2015-05-06 16:31:19 +01:00
18 changed files with 5577 additions and 532 deletions

153
.eslintrc
View file

@ -1,155 +1,12 @@
root: true
env:
mocha: true
node: true
# globals:
#########################
## Only add globals if you're absolutely certain they need to be globals
##########################
# console: true
#########################
## set to 0 to allow
## set to 1 to disallow as warning
## set to 2 to disallow as error
#########################
rules:
#########################
## Optional Rules
#########################
# Disallow use of `console`
no-console: 2
# Disallow warning comments
no-warning-comments:
- 1
- terms
- todo
- fixme
location
- anywhere
# Warns when variables are defined but never used
no-unused-vars: 1
# Enforces comma style (first or last)
comma-style:
max-len:
- 2
- last
# Enforces one true `this` variable
consistent-this:
- 2
- self
# Allows dangling underscores in identifiers
no-underscore-dangle: 2
# Enforces function expressions to have a name
func-names: 0
# Set maximum depth of nested callbacks
max-nested-callbacks:
- 1
- 3
#########################
## Core Rules
##########################
# Enforces camel case names
camelcase: 2
# Prohibit use of == and != in favor of === and !==
eqeqeq: 2
# Suppresses warnings about == null comparisons
no-eq-null: 2
# No mixing tabs and spaces, with 2 spaces only
no-mixed-spaces-and-tabs: 2
# Prohibits use of a variable before it is defined
no-use-before-define: 2
# Requires capitalized names for constructor functions
new-cap: 2
# Prohibits use of explicitly undeclared variables
no-undef: 2
# Enforces Use Strict at the top of function scope
strict:
- 2
- global
# Requires variable declarations to be at the top
vars-on-top: 2
# Enforce curly braces around blocks in loops and conditionals
curly: 2
# Prohibits the use of immediate function invocations w/o wrapping in parentheses
wrap-iife: 2
# Prohibits `argument.caller` and `argument.callee`
no-caller: 2
# Requires all `for in` loops to filter object's items
guard-for-in: 2
# Prohibits comparing a variable against itself
no-self-compare: 2
# Prohibits use of `undefined` variable
no-undefined: 0
# Prohibits nested ternaries
no-nested-ternary: 2
# Enforces a space before blocks
space-before-blocks:
- 2
- always
# Enforces spaces following keywords
space-after-keywords:
- 2
- always
- checkFunctionKeyword: true
# Enforces quoted property names
quote-props:
- 2
- always
# Enforces padded blocks
padded-blocks:
- 1
- never
# Enforce functions as expressions
func-style:
- 2
- expression
# Require brace style
brace-style:
- 2
- stroustrup
# Prohibits Yoda conditions
yoda:
- 2
- never
# Enforce use of single quotation marks for strings.
quotes:
- 2
- single
# Enforces space inside of brackets (except property name)
space-in-brackets:
- 2
- always
- propertyName: false
singleValue: false
- 120
extends: "airbnb-base"

25
.gitlab-ci.yml Normal file
View file

@ -0,0 +1,25 @@
default:
before_script:
- yarn
node12:
image: node:12
allow_failure: true
script:
- yarn test
node13:
image: node:13
allow_failure: true
script:
- yarn test
node14:
image: node:14
script:
- yarn test
node15:
image: node:15
script:
- yarn test

View file

@ -1,5 +1,8 @@
sudo: false
language: node_js
node_js:
- "0.10"
- node
- iojs
- lts/boron
- lts/carbon
- current

View file

@ -1,5 +1,114 @@
# Gulp Sass Changelog
## v4.2.0
**November 6, 2020**
https://git.sakamoto.pl/selfisekai/gulp-sass/-/tags/v4.2.0
## v4.1.0
**April 23, 2020**
https://github.com/dlmanning/gulp-sass/releases/tag/v4.1.0
## v4.0.2
**October 16, 2018**
https://github.com/dlmanning/gulp-sass/releases/tag/v4.0.2
## v4.0.1
**Apr 8, 2018**
https://github.com/dlmanning/gulp-sass/releases/tag/v4.0.1
## v4.0.0
**April 5, 2018**
https://github.com/dlmanning/gulp-sass/releases/tag/v4.0.0
## v3.2.1
**March 24, 2018**
https://github.com/dlmanning/gulp-sass/releases/tag/v3.2.1
## v3.2.0
**March 12, 2018**
https://github.com/dlmanning/gulp-sass/releases/tag/v3.2.0
## v3.1.0
**January 9, 2017**
https://github.com/dlmanning/gulp-sass/releases/tag/v3.1.0
## v3.0.0
**January 9, 2017**
https://github.com/dlmanning/gulp-sass/releases/tag/v3.0.0
## v2.3.2
**June 15, 2016**
https://github.com/dlmanning/gulp-sass/releases/tag/v2.3.2
## v2.3.1
**April 22, 2016**
https://github.com/dlmanning/gulp-sass/releases/tag/v2.3.1
## v2.3.0
**April 21, 2016**
https://github.com/dlmanning/gulp-sass/releases/tag/v2.3.0
## v2.3.0-beta.1
**February 4, 2016**
https://github.com/dlmanning/gulp-sass/releases/tag/v2.3.0-beta.1
## v2.2.0
**February 4, 2016**
https://github.com/dlmanning/gulp-sass/releases/tag/v2.2.0
## v2.1.0
**November 2, 2015**
https://github.com/dlmanning/gulp-sass/releases/tag/v2.1.0
## v2.1.0-beta
**September 21, 2015**
* **Change** :arrow_up: Bump to Node Sass 3.4.0-beta1
## v2.0.4
**July 15, 2015**
* **Fix** Relative file path now uses `file.relative` instead of arcane `split('/').pop` magic. Resolves lots of issues with source map paths.
* **Fix** Empty partials no longer copied to CSS folder
## v2.0.3
**June 27, 2015**
* **Fix** Empty partials no longer copied to CSS folder
## v2.0.2
**June 25, 2015**
* **Fix** Error in watch stream preventing watch from continuing
## v2.0.1
**May 13, 2015**
* **Fix** Source maps now work as expected with Autoprefixer
* **Fix** Current file directory `unshift` onto includePaths stack so it's checked first
* **Fix** Error message returned is unformatted so as to not break other error handling (*i.e.* `gulp-notify`)
## v2.0.0
**May 6, 2015**
* **Change** :arrow_up: Bump to Node Sass 3.0.0
## v2.0.0-alpha.1
**March 26, 2015**

View file

@ -4,11 +4,11 @@ Gulp Sass is a very light-weight [Gulp](https://github.com/gulpjs/gulp) wrapper
## Submitting Issues
* Before creating a new issue, perform a [cursory search](https://github.com/issues?utf8=%E2%9C%93&q=repo%3Adlmanning%2Fgulp-sass+repo%3Asass%2Fnode-sass+repo%3Asass%2Flibsass+repo%3Asass%2Fsass+repo%3Asass-eyeglass%2Feyeglass) in the Gulp Sass, Node Sass, Libsass, and main Sass repos to see if a similar issue has already been submitted.
* Before creating a new issue, perform a [cursory search](https://github.com/issues?utf8=%E2%9C%93&q=repo%3Adlmanning%2Fgulp-sass+repo%3Asass%2Fnode-sass+repo%3Asass%2Flibsass+repo%3Asass%2Fsass+repo%3Asass-eyeglass%2Feyeglass) in the Gulp Sass, Node Sass, Libsass, and main Sass repos to see if a similar issue has already been submitted. Please also refer to our [Common Issues and Their Fixes](https://github.com/dlmanning/gulp-sass/wiki/Common-Issues-and-Their-Fixes) page for some basic troubleshooting.
* You can create an issue [here](https://github.com/dlmanning/gulp-sass/issues). Please include as many details as possible in your report.
* Issue titles should be descriptive, explaining at the high level what it is about.
* Please include the version of `gulp-sass` you are using.
* Do not open a [pull request](#pull-requests) to resolve an issue without first receiving feedback from a `collaborator` or `owner` and having them agree on a solution forward.
* Please include the version of `gulp-sass`, Node, and NPM you are using, as well as what operating system you are having a problem on.
* _Do not open a [pull request](#pull-requests) to resolve an issue without first receiving feedback from a `collaborator` or `owner` and having them agree on a solution forward_.
* Include screenshots and animated GIFs whenever possible; they are immensely helpful.
* Issues that have a number of sub-items that need to be complete should use [task lists](https://github.com/blog/1375%0A-task-lists-in-gfm-issues-pulls-comments) to track the sub-items in the main issue comment.

177
LICENSE
View file

@ -1,20 +1,165 @@
The MIT License (MIT)
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (c) 2013 David Manning
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

108
README.md
View file

@ -1,11 +1,19 @@
# gulp-sass [![Build Status](https://travis-ci.org/dlmanning/gulp-sass.svg?branch=master)](https://travis-ci.org/dlmanning/gulp-sass) [![Join the chat at https://gitter.im/dlmanning/gulp-sass](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/dlmanning/gulp-sass?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
# gulp-sass
Sass plugin for [Gulp](https://github.com/gulpjs/gulp).
This is a fork of [David Manning's Gulp Sass](https://github.com/dlmanning/gulp-sass).
# Support
Only [Active LTS and Current releases][1] are supported.
[1]: https://github.com/nodejs/Release#release-schedule
# Install
```
npm install gulp-sass --save-dev
yarn add --dev sass @selfisekai/gulp-sass
```
# Basic Usage
@ -13,65 +21,119 @@ npm install gulp-sass --save-dev
Something like this will compile your Sass files:
```javascript
var gulp = require('gulp');
var sass = require('gulp-sass');
'use strict';
gulp.task('sass', function () {
gulp.src('./scss/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('./css'));
const gulp = require('gulp');
const sass = require('@selfisekai/gulp-sass');
sass.compiler = require('sass');
gulp.task('sass', () => {
return gulp.src('./sass/**/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('./css'));
});
gulp.task('sass:watch', () => {
gulp.watch('./sass/**/*.scss', ['sass']);
});
```
You can also compile synchronously, doing something like this:
```javascript
var gulp = require('gulp');
var sass = require('gulp-sass');
'use strict';
gulp.task('sass', function () {
gulp.src('./scss/*.scss')
const gulp = require('gulp');
const sass = require('@selfisekai/gulp-sass');
sass.compiler = require('sass');
gulp.task('sass', () => {
return gulp.src('./sass/**/*.scss')
.pipe(sass.sync().on('error', sass.logError))
.pipe(gulp.dest('./css'));
});
gulp.task('sass:watch', () => {
gulp.watch('./sass/**/*.scss', ['sass']);
});
```
You can choose whether to use [Dart Sass][] or [Node Sass][] by setting the `sass.compiler` property. Dart Sass will be used by default, but it's strongly recommended that you set it explicitly for forwards-compatibility in case the default ever changes.
Compiler | Maintained | No installation problems
------------|------------|-------------------------
[Dart Sass] | yes | yes
[Node Sass] | no | no
[Dart Sass]: http://sass-lang.com/dart-sass
[Node Sass]: https://github.com/sass/node-sass
Note that when using Dart Sass, **synchronous compilation is twice as fast as asynchronous compilation** by default, due to the overhead of asynchronous callbacks.
## Options
Pass in options just like you would for [`node-sass`](https://github.com/sass/node-sass#options); they will be passed along just as if you were using `node-sass`.
Pass in options just like you would for [Node Sass](https://github.com/sass/node-sass#options); they will be passed along just as if you were using Node Sass. Except for the `data` option which is used by gulp-sass internally. Using the `file` option is also unsupported and results in undefined behaviour that may change without notice.
For example:
```javascript
gulp.task('sass', () => {
return gulp.src('./sass/**/*.scss')
.pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError))
.pipe(gulp.dest('./css'));
});
```
Or this for synchronous code:
```javascript
gulp.task('sass', () => {
return gulp.src('./sass/**/*.scss')
.pipe(sass.sync({outputStyle: 'compressed'}).on('error', sass.logError))
.pipe(gulp.dest('./css'));
});
```
## Source Maps
`gulp-sass` can be used in tandem with [gulp-sourcemaps](https://github.com/floridoo/gulp-sourcemaps) to generate source maps for the Sass to CSS compilation. You will need to initialize [gulp-sourcemaps](https://github.com/floridoo/gulp-sourcemaps) prior to running `gulp-sass` and write the source maps after.
```javascript
var sourcemaps = require('gulp-sourcemaps');
const sourcemaps = require('gulp-sourcemaps');
gulp.src('./scss/*.scss')
gulp.task('sass', () => {
return gulp.src('./sass/**/*.scss')
.pipe(sourcemaps.init())
.pipe(sass())
.pipe(sass().on('error', sass.logError))
.pipe(sourcemaps.write())
.pipe(gulp.dest('./css'));
});
```
By default, [gulp-sourcemaps](https://github.com/floridoo/gulp-sourcemaps) writes the source maps inline in the compiled CSS files. To write them to a separate file, specify a path relative to the `gulp.dest()` destination in the `sourcemaps.write()` function.
```javascript
var sourcemaps = require('gulp-sourcemaps');
gulp.src('./scss/*.scss')
const sourcemaps = require('gulp-sourcemaps');
gulp.task('sass', () => {
return gulp.src('./sass/**/*.scss')
.pipe(sourcemaps.init())
.pipe(sass())
.pipe(sass().on('error', sass.logError))
.pipe(sourcemaps.write('./maps'))
.pipe(gulp.dest('./css'));
});
```
# Issues
`gulp-sass` is a very light-weight wrapper around [`node-sass`](https://github.com/sass/node-sass), which in turn is a Node binding for [`libsass`](https://github.com/sass/libsass), which in turn is a port of [`Sass`](https://github.com/sass/sass). Because of this, the issue you're having likely isn't a `gulp-sass` issue, but an issue with one of those three projects.
`gulp-sass` is a very light-weight wrapper around either [Dart Sass][] or [Node Sass][] (which in turn is a Node binding for [LibSass][]). Because of this, the issue you're having likely isn't a `gulp-sass` issue, but an issue with one those projects or with [Sass][] as a whole.
If you have a feature request/question how Sass works/concerns on how your Sass gets compiled/errors in your compiling, it's likely a `libsass` or `Sass` issue and you should file your issue with one of those projects.
[LibSass]: https://sass-lang.com/libsass
[Sass]: https://sass-lang.com
If you're having problems with the options you're passing in, it's likely a `node-sass` or `libsass` issued and you should file your issue with one of those projects.
If you have a feature request/question how Sass works/concerns on how your Sass gets compiled/errors in your compiling, it's likely a Dart Sass or LibSass issue and you should file your issue with one of those projects.
If you're having problems with the options you're passing in, it's likely a Dart Sass or Node Sass issue and you should file your issue with one of those projects.
We may, in the course of resolving issues, direct you to one of these other projects. If we do so, please follow up by searching that project's issue queue (both open and closed) for your problem and, if it doesn't exist, filing an issue with them.

25
appveyor.yml Normal file
View file

@ -0,0 +1,25 @@
version: "{build}"
cache:
- '%AppData%\npm-cache'
build: off
platform:
- x64
- x86
environment:
matrix:
- nodejs_version: 6
- nodejs_version: 8
- nodejs_version: 9
install:
- ps: Install-Product node $env:nodejs_version $env:platform
- npm install
test_script:
- node --version
- npm --version
- npm test

44
index.d.ts vendored Normal file
View file

@ -0,0 +1,44 @@
// Type definitions originally for gulp-sass 4.0.2
// Project: https://github.com/dlmanning/gulp-sass
// Definitions by: Asana <https://asana.com>
// Yuma Hashimoto <https://github.com/yuma84>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.7
/// <reference types="node"/>
import { Options } from 'sass';
interface SassResults {
css: string;
map: string;
stats: {
entry: string;
start: Date;
end: Date;
duration: number;
includedFiles: string[];
}
}
interface SassOptions extends Options {
success?: (results: SassResults) => any;
error?: (err: Error) => any;
imagePaths?: string[];
}
interface GulpSassOptions extends SassOptions {
errLogToConsole?: boolean;
onSuccess?: (css: string) => any;
onError?: (err: Error) => any;
sync?: boolean;
}
interface Sass {
(opts?: GulpSassOptions): NodeJS.ReadWriteStream;
logError(error?: string): void;
sync(options?: GulpSassOptions): NodeJS.ReadWriteStream;
}
declare var _tmp: Sass;
export = _tmp;

283
index.js
View file

@ -1,156 +1,183 @@
'use strict';
/* eslint-disable global-require */
/* eslint-disable import/no-extraneous-dependencies */
var gutil = require('gulp-util');
var through = require('through2');
var assign = require('object-assign');
var path = require('path');
var applySourceMap = require('vinyl-sourcemaps-apply');
const chalk = require('chalk');
const PluginError = require('plugin-error');
const replaceExtension = require('replace-ext');
const stripAnsi = require('strip-ansi');
const through = require('through2');
const clonedeep = require('lodash/cloneDeep');
const path = require('path');
const applySourceMap = require('vinyl-sourcemaps-apply');
var PLUGIN_NAME = 'gulp-sass';
const PLUGIN_NAME = 'gulp-sass';
//////////////////////////////
// ////////////////////////////
// Main Gulp Sass function
//////////////////////////////
var gulpSass = function gulpSass(options, sync) {
return through.obj(function(file, enc, cb) {
var opts,
filePush,
errorM,
callback,
result;
// ////////////////////////////
const gulpSass = (options, sync) => through.obj((file, enc, cb) => { // eslint-disable-line consistent-return
if (file.isNull()) {
return cb(null, file);
}
if (file.isNull()) {
return cb(null, file);
}
if (file.isStream()) {
return cb(new gutil.PluginError(PLUGIN_NAME, 'Streaming not supported'));
}
if (path.basename(file.path).indexOf('_') === 0) {
return cb();
if (file.isStream()) {
return cb(new PluginError(PLUGIN_NAME, 'Streaming not supported'));
}
if (path.basename(file.path).indexOf('_') === 0) {
return cb();
}
if (!file.contents.length) {
file.path = replaceExtension(file.path, '.css'); // eslint-disable-line no-param-reassign
return cb(null, file);
}
const opts = clonedeep(options || {});
opts.data = file.contents.toString();
// we set the file path here so that libsass can correctly resolve import paths
opts.file = file.path;
// Ensure `indentedSyntax` is true if a `.sass` file
if (path.extname(file.path) === '.sass') {
opts.indentedSyntax = true;
}
// Ensure file's parent directory in the include path
if (opts.includePaths) {
if (typeof opts.includePaths === 'string') {
opts.includePaths = [opts.includePaths];
}
} else {
opts.includePaths = [];
}
opts = assign({}, options);
opts.data = file.contents.toString();
opts.includePaths.unshift(path.dirname(file.path));
// Ensure `indentedSyntax` is true if a `.sass` file
if (path.extname(file.path) === '.sass') {
opts.indentedSyntax = true;
}
// Generate Source Maps if plugin source-map present
if (file.sourceMap) {
opts.sourceMap = file.path;
opts.omitSourceMapUrl = true;
opts.sourceMapContents = true;
}
// Ensure file's parent directory in the include path
if (opts.includePaths) {
if (typeof opts.includePaths === 'string') {
opts.includePaths = [opts.includePaths];
}
}
else {
opts.includePaths = [];
}
// ////////////////////////////
// Handles returning the file to the stream
// ////////////////////////////
const filePush = (sassObj) => {
let sassMap;
let sassMapFile;
let sassFileSrc;
let sassFileSrcPath;
let sourceFileIndex;
opts.includePaths.push(path.dirname(file.path));
// Generate Source Maps if plugin source-map present
if (file.sourceMap) {
opts.sourceMap = file.path;
opts.omitSourceMapUrl = true;
}
//////////////////////////////
// Handles returning the file to the stream
//////////////////////////////
filePush = function filePush(sassObj) {
var sassMap,
sassMapFile,
sassFileSrc;
// Build Source Maps!
if (sassObj.map) {
// Transform map into JSON
sassMap = JSON.parse(sassObj.map.toString());
// Grab the stdout and transform it into stdin
sassMapFile = sassMap.file.replace('stdout', 'stdin');
// Grab the base file name that's being worked on
sassFileSrc = file.path.split('/').pop();
// Replace the stdin with the original file name
sassMap.sources[sassMap.sources.indexOf(sassMapFile)] = sassFileSrc;
// Replace the map file with the original file name
sassMap.file = sassFileSrc;
// Apply the map
applySourceMap(file, sassMap);
// Build Source Maps!
if (sassObj.map) {
// Transform map into JSON
sassMap = JSON.parse(sassObj.map.toString());
// Grab the stdout and transform it into stdin
sassMapFile = sassMap.file.replace(/^stdout$/, 'stdin');
// Grab the base file name that's being worked on
sassFileSrc = file.relative;
// Grab the path portion of the file that's being worked on
sassFileSrcPath = path.dirname(sassFileSrc);
if (sassFileSrcPath) {
// Prepend the path to all files in the sources array except the file that's being worked on
sourceFileIndex = sassMap.sources.indexOf(sassMapFile);
sassMap.sources = sassMap.sources.map((source, index) => { // eslint-disable-line arrow-body-style
return index === sourceFileIndex ? source : path.join(sassFileSrcPath, source);
});
}
file.contents = sassObj.css;
file.path = gutil.replaceExtension(file.path, '.css');
// Remove 'stdin' from souces and replace with filenames!
sassMap.sources = sassMap.sources.filter(src => src !== 'stdin' && src);
cb(null, file);
};
//////////////////////////////
// Handles error message
//////////////////////////////
errorM = function errorM(error) {
var relativePath = '',
filePath = error.file === 'stdin' ? file.path : error.file,
message = '';
filePath = filePath ? filePath : file.path;
relativePath = path.relative(process.cwd(), filePath);
message += gutil.colors.underline(relativePath) + '\n';
message += gutil.colors.gray(' ' + error.line + ':' + error.column) + ' ';
message += error.message;
return cb(new gutil.PluginError(
PLUGIN_NAME, message
));
};
if (sync !== true) {
//////////////////////////////
// Async Sass render
//////////////////////////////
callback = function(error, obj) {
if (error) {
return errorM(error);
}
filePush(obj);
};
gulpSass.compiler.render(opts, callback);
// Replace the map file with the original file name (but new extension)
sassMap.file = replaceExtension(sassFileSrc, '.css');
// Apply the map
applySourceMap(file, sassMap);
}
else {
//////////////////////////////
// Sync Sass render
//////////////////////////////
try {
result = gulpSass.compiler.renderSync(opts);
filePush(result);
}
catch(error) {
file.contents = sassObj.css; // eslint-disable-line no-param-reassign
file.path = replaceExtension(file.path, '.css'); // eslint-disable-line no-param-reassign
if (file.stat) {
file.stat.atime = file.stat.mtime = file.stat.ctime = new Date(); // eslint-disable-line
}
cb(null, file);
};
// ////////////////////////////
// Handles error message
// ////////////////////////////
const errorM = (error) => {
const filePath = (error.file === 'stdin' ? file.path : error.file) || file.path;
const relativePath = path.relative(process.cwd(), filePath);
const message = [chalk.underline(relativePath), error.formatted].join('\n');
error.messageFormatted = message; // eslint-disable-line no-param-reassign
error.messageOriginal = error.message; // eslint-disable-line no-param-reassign
error.message = stripAnsi(message); // eslint-disable-line no-param-reassign
error.relativePath = relativePath; // eslint-disable-line no-param-reassign
return cb(new PluginError(PLUGIN_NAME, error));
};
if (sync !== true) {
// ////////////////////////////
// Async Sass render
// ////////////////////////////
const callback = (error, obj) => { // eslint-disable-line consistent-return
if (error) {
return errorM(error);
}
filePush(obj);
};
gulpSass.compiler.render(opts, callback);
} else {
// ////////////////////////////
// Sync Sass render
// ////////////////////////////
try {
filePush(gulpSass.compiler.renderSync(opts));
} catch (error) {
return errorM(error);
}
});
};
}
});
//////////////////////////////
// ////////////////////////////
// Sync Sass render
//////////////////////////////
gulpSass.sync = function sync(options) {
return gulpSass(options, true);
};
// ////////////////////////////
gulpSass.sync = options => gulpSass(options, true);
//////////////////////////////
// ////////////////////////////
// Log errors nicely
//////////////////////////////
// ////////////////////////////
gulpSass.logError = function logError(error) {
gutil.log(gutil.colors.red('[' + PLUGIN_NAME + '] ') + error.message);
const message = new PluginError('sass', error.messageFormatted).toString();
process.stderr.write(`${message}\n`);
this.emit('end');
};
//////////////////////////////
// ////////////////////////////
// Store compiler in a prop
//////////////////////////////
gulpSass.compiler = require('node-sass');
// ////////////////////////////
gulpSass.compiler = (() => {
try {
// eslint-disable-next-line global-require import/no-extraneous-dependencies
return require('sass');
} catch (e1) {
try {
// eslint-disable-next-line global-require import/no-extraneous-dependencies
return require('node-sass');
} catch (e2) {
throw new Error(`${PLUGIN_NAME}: you need either sass or node-sass module in your project`);
}
}
})();
module.exports = gulpSass;

View file

@ -1,35 +1,55 @@
{
"name": "gulp-sass",
"version": "2.0.0",
"description": "Gulp plugin for sass",
"name": "@selfisekai/gulp-sass",
"version": "4.2.0",
"description": "Gulp plugin for sass (forked)",
"main": "index.js",
"scripts": {
"test": "./node_modules/.bin/mocha test"
"test": "yarn mocha test"
},
"repository": {
"type": "git",
"url": "git://github.com/dlmanning/gulp-sass"
"url": "https://git.sakamoto.pl/selfisekai/gulp-sass.git"
},
"keywords": [
"gulpplugin",
"sass",
"gulp"
],
"author": "David Manning",
"license": "MIT",
"author": "Laura Liberda (originally: David Manning)",
"license": "LGPL-3.0",
"bugs": {
"url": "https://github.com/dlmanning/gulp-sass/issues"
"email": "gulp-sass@selfisekai.rocks"
},
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
},
"dependencies": {
"gulp-util": "^3.0",
"node-sass": "^3.0.0",
"object-assign": "^2.0.0",
"through2": "^0.6.3",
"vinyl-sourcemaps-apply": "~0.1.1"
"@types/sass": "^1.16.0",
"chalk": "^2.3.0",
"lodash": "^4.17.11",
"plugin-error": "^1.0.1",
"replace-ext": "^1.0.0",
"strip-ansi": "^4.0.0",
"through2": "^2.0.0",
"vinyl-sourcemaps-apply": "^0.2.0"
},
"devDependencies": {
"eslint": "^0.17.1",
"mocha": "^2.2.1",
"should": "^5.2.0"
"@types/node-sass": "^4.11.1",
"autoprefixer": "^8.1.0",
"eslint": "^4.18.2",
"eslint-config-airbnb-base": "^12.1.0",
"eslint-plugin-import": "^2.9.0",
"globule": "^1.0.0",
"gulp": "^4.0.2",
"gulp-postcss": "^7.0.1",
"gulp-sourcemaps": "^2.6.4",
"gulp-tap": "^0.1.3",
"mocha": "^5.0.4",
"node-sass": "^5.0.0",
"rimraf": "^2.4.3",
"sass": "^1.29.0",
"should": "^13.2.1",
"vinyl": "^2.1.0"
}
}

0
test/expected/empty.css Normal file
View file

View file

@ -1,16 +1,12 @@
'use strict';
const eslint = require('eslint');
const should = require('should');
var eslint = require('eslint');
var should = require('should');
describe('code style guide', () => {
it('index.js should follow our lint style guide', (done) => {
const cli = new eslint.CLIEngine({ rules: { 'spaced-comment': 0 } });
const formatter = cli.getFormatter();
const report = cli.executeOnFiles(['index.js']);
var cli = new eslint.CLIEngine();
var formatter = cli.getFormatter();
var report;
describe('code style guide', function() {
it('index.js should follow our lint style guide', function(done) {
report = cli.executeOnFiles(['index.js']);
if (report.errorCount > 0 || report.warningCount > 0) {
console.log(formatter(report.results));
}
@ -20,8 +16,11 @@ describe('code style guide', function() {
done();
});
it('test/main.js should follow our lint style guide', function(done) {
report = cli.executeOnFiles(['test/main.js']);
it('test/main.js should follow our lint style guide', (done) => {
const cli = new eslint.CLIEngine();
const formatter = cli.getFormatter();
const report = cli.executeOnFiles(['test/main.js']);
if (report.errorCount > 0 || report.warningCount > 0) {
console.log(formatter(report.results));
}
@ -31,13 +30,11 @@ describe('code style guide', function() {
done();
});
it('test/lint.js should follow our lint style guide', function(done) {
cli = new eslint.CLIEngine({
'rules': {
'no-console': 0
}
});
report = cli.executeOnFiles(['test/lint.js']);
it('test/lint.js should follow our lint style guide', (done) => {
const cli = new eslint.CLIEngine({ rules: { 'no-console': 0 } });
const formatter = cli.getFormatter();
const report = cli.executeOnFiles(['test/lint.js']);
if (report.errorCount > 0 || report.warningCount > 0) {
console.log(formatter(report.results));
}

View file

@ -1,183 +1,229 @@
'use strict';
const should = require('should');
const Vinyl = require('vinyl');
const path = require('path');
const fs = require('fs');
const sass = require('../index');
sass.compiler = require('node-sass');
const rimraf = require('rimraf');
const gulp = require('gulp');
const sourcemaps = require('gulp-sourcemaps');
const postcss = require('gulp-postcss');
const autoprefixer = require('autoprefixer');
const tap = require('gulp-tap');
const globule = require('globule');
var should = require('should');
var gutil = require('gulp-util');
var path = require('path');
var fs = require('fs');
var sass = require('../index');
const createVinyl = (filename, contents) => {
const base = path.join(__dirname, 'scss');
const filePath = path.join(base, filename);
var createVinyl = function createVinyl(filename, contents) {
var base = path.join(__dirname, 'scss');
var filePath = path.join(base, filename);
return new gutil.File({
'cwd': __dirname,
'base': base,
'path': filePath,
'contents': contents || fs.readFileSync(filePath)
return new Vinyl({
cwd: __dirname,
base,
path: filePath,
contents: contents || fs.readFileSync(filePath),
});
};
describe('gulp-sass -- async compile', function() {
it('should pass file when it isNull()', function(done) {
var stream = sass();
var emptyFile = {
'isNull': function () {
return true;
}
const normaliseEOL = str => str.toString('utf8').replace(/\r\n/g, '\n');
describe('test helpers', () => {
it('should normalise EOL', (done) => {
should.equal(normaliseEOL('foo\r\nbar'), 'foo\nbar');
should.equal(normaliseEOL('foo\nbar'), 'foo\nbar');
done();
});
});
describe('gulp-sass -- async compile', () => {
it('should pass file when it isNull()', (done) => {
const stream = sass();
const emptyFile = {
isNull: () => true,
};
stream.on('data', function(data) {
stream.on('data', (data) => {
data.should.equal(emptyFile);
done();
});
stream.write(emptyFile);
});
it('should emit error when file isStream()', function (done) {
var stream = sass();
var streamFile = {
'isNull': function () {
return false;
},
'isStream': function () {
return true;
}
it('should emit error when file isStream()', (done) => {
const stream = sass();
const streamFile = {
isNull: () => false,
isStream: () => true,
};
stream.on('error', function(err) {
stream.on('error', (err) => {
err.message.should.equal('Streaming not supported');
done();
});
stream.write(streamFile);
});
it('should compile a single sass file', function(done) {
var sassFile = createVinyl('mixins.scss');
var stream = sass();
stream.on('data', function(cssFile) {
it('should compile an empty sass file', (done) => {
const sassFile = createVinyl('empty.scss');
const stream = sass();
stream.on('data', (cssFile) => {
should.exist(cssFile);
should.exist(cssFile.path);
should.exist(cssFile.relative);
should.exist(cssFile.contents);
String(cssFile.contents).should.equal(
fs.readFileSync(path.join(__dirname, 'expected/mixins.css'), 'utf8')
);
should.equal(path.basename(cssFile.path), 'empty.css');
const actual = fs.readFileSync(path.join(__dirname, 'expected', 'empty.css'), 'utf8');
String(normaliseEOL(cssFile.contents)).should.equal(normaliseEOL(actual));
done();
});
stream.write(sassFile);
});
it('should compile multiple sass files', function(done) {
var files = [
createVinyl('mixins.scss'),
createVinyl('variables.scss')
];
var stream = sass();
var mustSee = files.length;
var expectedPath = 'expected/mixins.css';
it('should compile a single sass file', (done) => {
const sassFile = createVinyl('mixins.scss');
const stream = sass();
stream.on('data', (cssFile) => {
should.exist(cssFile);
should.exist(cssFile.path);
should.exist(cssFile.relative);
should.exist(cssFile.contents);
stream.on('data', function(cssFile) {
const actual = fs.readFileSync(path.join(__dirname, 'expected', 'mixins.css'), 'utf8');
String(normaliseEOL(cssFile.contents)).should.equal(normaliseEOL(actual));
done();
});
stream.write(sassFile);
});
it('should compile multiple sass files', (done) => {
const files = [
createVinyl('mixins.scss'),
createVinyl('variables.scss'),
];
const stream = sass();
let mustSee = files.length;
let expectedPath = path.join('expected', 'mixins.css');
stream.on('data', (cssFile) => {
should.exist(cssFile);
should.exist(cssFile.path);
should.exist(cssFile.relative);
should.exist(cssFile.contents);
if (cssFile.path.indexOf('variables') !== -1) {
expectedPath = 'expected/variables.css';
expectedPath = path.join('expected', 'variables.css');
}
String(cssFile.contents).should.equal(
fs.readFileSync(path.join(__dirname, expectedPath), 'utf8')
);
mustSee--;
const actual = fs.readFileSync(path.join(__dirname, expectedPath), 'utf8');
String(normaliseEOL(cssFile.contents)).should.equal(normaliseEOL(actual));
mustSee -= 1;
if (mustSee <= 0) {
done();
}
});
files.forEach(function (file) {
files.forEach((file) => {
stream.write(file);
});
});
it('should compile files with partials in another folder', function(done) {
var sassFile = createVinyl('inheritance.scss');
var stream = sass();
stream.on('data', function(cssFile) {
it('should compile files with partials in another folder', (done) => {
const sassFile = createVinyl('inheritance.scss');
const stream = sass();
stream.on('data', (cssFile) => {
should.exist(cssFile);
should.exist(cssFile.path);
should.exist(cssFile.relative);
should.exist(cssFile.contents);
String(cssFile.contents).should.equal(
fs.readFileSync(path.join(__dirname, 'expected/inheritance.css'), 'utf8')
);
const actual = fs.readFileSync(path.join(__dirname, 'expected', 'inheritance.css'), 'utf8');
String(normaliseEOL(cssFile.contents)).should.equal(normaliseEOL(actual));
done();
});
stream.write(sassFile);
});
it('should handle sass errors', function(done) {
var errorFile = createVinyl('error.scss');
var stream = sass();
it('should emit logError on sass error', (done) => {
const errorFile = createVinyl('error.scss');
const stream = sass();
stream.on('error', function(err) {
stream.on('error', sass.logError);
stream.on('end', done);
stream.write(errorFile);
});
it('should handle sass errors', (done) => {
const errorFile = createVinyl('error.scss');
const stream = sass();
stream.on('error', (err) => {
// Error must include message body
err.message.indexOf('property "font" must be followed by a \':\'').should.not.equal(-1);
// Error must include file error occurs in
err.message.indexOf('test', 'scss', 'error.scss').should.not.equal(-1);
// Error must include line and column error occurs on
err.message.indexOf('on line 2').should.not.equal(-1);
// Error must include relativePath property
err.relativePath.should.equal(path.join('test', 'scss', 'error.scss'));
done();
});
stream.write(errorFile);
});
it('should compile a single sass file if the file name has been changed in the stream', function(done) {
var sassFile = createVinyl('mixins.scss');
var stream;
it('should preserve the original sass error message', (done) => {
const errorFile = createVinyl('error.scss');
const stream = sass();
stream.on('error', (err) => {
// Error must include original error message
err.messageOriginal.indexOf('property "font" must be followed by a \':\'').should.not.equal(-1);
// Error must not format or change the original error message
err.messageOriginal.indexOf('on line 2').should.equal(-1);
done();
});
stream.write(errorFile);
});
it('should compile a single sass file if the file name has been changed in the stream', (done) => {
const sassFile = createVinyl('mixins.scss');
// Transform file name
sassFile.path = path.join(path.join(__dirname, 'scss'), 'mixin--changed.scss');
stream = sass();
stream.on('data', function(cssFile) {
const stream = sass();
stream.on('data', (cssFile) => {
should.exist(cssFile);
should.exist(cssFile.path);
cssFile.path.split('/').pop().should.equal('mixin--changed.css');
cssFile.path.split(path.sep).pop().should.equal('mixin--changed.css');
should.exist(cssFile.relative);
should.exist(cssFile.contents);
String(cssFile.contents).should.equal(
fs.readFileSync(path.join(__dirname, 'expected/mixins.css'), 'utf8')
);
const actual = fs.readFileSync(path.join(__dirname, 'expected', 'mixins.css'), 'utf8');
String(normaliseEOL(cssFile.contents)).should.equal(normaliseEOL(actual));
done();
});
stream.write(sassFile);
});
it('should preserve changes made in-stream to a Sass file', function(done) {
var sassFile = createVinyl('mixins.scss');
var stream;
it('should preserve changes made in-stream to a Sass file', (done) => {
const sassFile = createVinyl('mixins.scss');
// Transform file name
sassFile.contents = new Buffer('/* Added Dynamically */' + sassFile.contents.toString());
sassFile.contents = Buffer.from(`/* Added Dynamically */${sassFile.contents.toString()}`);
stream = sass();
stream.on('data', function(cssFile) {
const stream = sass();
stream.on('data', (cssFile) => {
should.exist(cssFile);
should.exist(cssFile.path);
should.exist(cssFile.relative);
should.exist(cssFile.contents);
String(cssFile.contents).should.equal('/* Added Dynamically */\n' +
fs.readFileSync(path.join(__dirname, 'expected/mixins.css'), 'utf8')
);
const actual = fs.readFileSync(path.join(__dirname, 'expected', 'mixins.css'), 'utf8');
String(normaliseEOL(cssFile.contents))
.should.equal(`/* Added Dynamically */\n${normaliseEOL(actual)}`);
done();
});
stream.write(sassFile);
});
it('should work with gulp-sourcemaps', function(done) {
var sassFile = createVinyl('inheritance.scss');
// Expected sources are relative to file.base
var expectedSources = [
'includes/_cats.scss',
'includes/_dogs.sass',
'inheritance.scss'
];
var stream;
it('should work with gulp-sourcemaps', (done) => {
const sassFile = createVinyl('inheritance.scss');
sassFile.sourceMap = '{' +
'"version": 3,' +
@ -188,8 +234,15 @@ describe('gulp-sass -- async compile', function() {
'"sourcesContent": [ "@import ../inheritance;" ]' +
'}';
stream = sass();
stream.on('data', function(cssFile) {
// Expected sources are relative to file.base
const expectedSources = [
'inheritance.scss',
'includes/_cats.scss',
'includes/_dogs.sass',
];
const stream = sass();
stream.on('data', (cssFile) => {
should.exist(cssFile.sourceMap);
cssFile.sourceMap.sources.should.eql(expectedSources);
done();
@ -197,172 +250,182 @@ describe('gulp-sass -- async compile', function() {
stream.write(sassFile);
});
it('should compile a single indented sass file', function(done) {
var sassFile = createVinyl('indent.sass');
var stream = sass();
stream.on('data', function(cssFile) {
it('should compile a single indented sass file', (done) => {
const sassFile = createVinyl('indent.sass');
const stream = sass();
stream.on('data', (cssFile) => {
should.exist(cssFile);
should.exist(cssFile.path);
should.exist(cssFile.relative);
should.exist(cssFile.contents);
String(cssFile.contents).should.equal(
fs.readFileSync(path.join(__dirname, 'expected/indent.css'), 'utf8')
);
const actual = fs.readFileSync(path.join(__dirname, 'expected', 'indent.css'), 'utf8');
String(normaliseEOL(cssFile.contents)).should.equal(normaliseEOL(actual));
done();
});
stream.write(sassFile);
});
it('should parse files in sass and scss', function(done) {
var files = [
it('should parse files in sass and scss', (done) => {
const files = [
createVinyl('mixins.scss'),
createVinyl('indent.sass')
createVinyl('indent.sass'),
];
var stream = sass();
var mustSee = files.length;
var expectedPath = 'expected/mixins.css';
const stream = sass();
let mustSee = files.length;
let expectedPath = path.join('expected', 'mixins.css');
stream.on('data', function(cssFile) {
stream.on('data', (cssFile) => {
should.exist(cssFile);
should.exist(cssFile.path);
should.exist(cssFile.relative);
should.exist(cssFile.contents);
if (cssFile.path.indexOf('indent') !== -1) {
expectedPath = 'expected/indent.css';
expectedPath = path.join('expected', 'indent.css');
}
String(cssFile.contents).should.equal(
fs.readFileSync(path.join(__dirname, expectedPath), 'utf8')
);
mustSee--;
const actual = fs.readFileSync(path.join(__dirname, expectedPath), 'utf8');
String(normaliseEOL(cssFile.contents)).should.equal(normaliseEOL(actual));
mustSee -= 1;
if (mustSee <= 0) {
done();
}
});
files.forEach(function (file) {
files.forEach((file) => {
stream.write(file);
});
});
});
describe('gulp-sass -- sync compile', function() {
it('should pass file when it isNull()', function(done) {
var stream = sass.sync();
var emptyFile = {
'isNull': function () {
return true;
}
describe('gulp-sass -- sync compile', () => {
beforeEach((done) => {
rimraf(path.join(__dirname, 'results'), done);
});
it('should pass file when it isNull()', (done) => {
const stream = sass.sync();
const emptyFile = {
isNull: () => true,
};
stream.on('data', function(data) {
stream.on('data', (data) => {
data.should.equal(emptyFile);
done();
});
stream.write(emptyFile);
});
it('should emit error when file isStream()', function (done) {
var stream = sass.sync();
var streamFile = {
'isNull': function () {
return false;
},
'isStream': function () {
return true;
}
it('should emit error when file isStream()', (done) => {
const stream = sass.sync();
const streamFile = {
isNull: () => false,
isStream: () => true,
};
stream.on('error', function(err) {
stream.on('error', (err) => {
err.message.should.equal('Streaming not supported');
done();
});
stream.write(streamFile);
});
it('should compile a single sass file', function(done) {
var sassFile = createVinyl('mixins.scss');
var stream = sass.sync();
stream.on('data', function(cssFile) {
it('should compile a single sass file', (done) => {
const sassFile = createVinyl('mixins.scss');
const stream = sass.sync();
stream.on('data', (cssFile) => {
should.exist(cssFile);
should.exist(cssFile.path);
should.exist(cssFile.relative);
should.exist(cssFile.contents);
String(cssFile.contents).should.equal(
fs.readFileSync(path.join(__dirname, 'expected/mixins.css'), 'utf8')
);
const actual = fs.readFileSync(path.join(__dirname, 'expected', 'mixins.css'), 'utf8');
String(normaliseEOL(cssFile.contents)).should.equal(normaliseEOL(actual));
done();
});
stream.write(sassFile);
});
it('should compile multiple sass files', function(done) {
var files = [
it('should compile multiple sass files', (done) => {
const files = [
createVinyl('mixins.scss'),
createVinyl('variables.scss')
createVinyl('variables.scss'),
];
var stream = sass.sync();
var mustSee = files.length;
var expectedPath = 'expected/mixins.css';
const stream = sass.sync();
let mustSee = files.length;
let expectedPath = path.join('expected', 'mixins.css');
stream.on('data', function(cssFile) {
stream.on('data', (cssFile) => {
should.exist(cssFile);
should.exist(cssFile.path);
should.exist(cssFile.relative);
should.exist(cssFile.contents);
if (cssFile.path.indexOf('variables') !== -1) {
expectedPath = 'expected/variables.css';
expectedPath = path.join('expected', 'variables.css');
}
String(cssFile.contents).should.equal(
fs.readFileSync(path.join(__dirname, expectedPath), 'utf8')
);
mustSee--;
const actual = normaliseEOL(fs.readFileSync(path.join(__dirname, expectedPath), 'utf8'));
String(normaliseEOL(cssFile.contents)).should.equal(actual);
mustSee -= 1;
if (mustSee <= 0) {
done();
}
});
files.forEach(function (file) {
files.forEach((file) => {
stream.write(file);
});
});
it('should compile files with partials in another folder', function(done) {
var sassFile = createVinyl('inheritance.scss');
var stream = sass.sync();
stream.on('data', function(cssFile) {
it('should compile files with partials in another folder', (done) => {
const sassFile = createVinyl('inheritance.scss');
const stream = sass.sync();
stream.on('data', (cssFile) => {
should.exist(cssFile);
should.exist(cssFile.path);
should.exist(cssFile.relative);
should.exist(cssFile.contents);
String(cssFile.contents).should.equal(
fs.readFileSync(path.join(__dirname, 'expected/inheritance.css'), 'utf8')
);
const actual = fs.readFileSync(path.join(__dirname, 'expected', 'inheritance.css'), 'utf8');
String(normaliseEOL(cssFile.contents)).should.equal(normaliseEOL(actual));
done();
});
stream.write(sassFile);
});
it('should handle sass errors', function(done) {
var errorFile = createVinyl('error.scss');
var stream = sass.sync();
it('should handle sass errors', (done) => {
const errorFile = createVinyl('error.scss');
const stream = sass.sync();
stream.on('error', function(err) {
stream.on('error', (err) => {
err.message.indexOf('property "font" must be followed by a \':\'').should.not.equal(-1);
err.relativePath.should.equal(path.join('test', 'scss', 'error.scss'));
done();
});
stream.write(errorFile);
});
it('should work with gulp-sourcemaps', function(done) {
var sassFile = createVinyl('inheritance.scss');
it('should emit logError on sass error', (done) => {
const errorFile = createVinyl('error.scss');
const stream = sass.sync();
stream.on('error', sass.logError);
stream.on('end', done);
stream.write(errorFile);
});
it('should work with gulp-sourcemaps', (done) => {
const sassFile = createVinyl('inheritance.scss');
// Expected sources are relative to file.base
var expectedSources = [
const expectedSources = [
'inheritance.scss',
'includes/_cats.scss',
'includes/_dogs.sass',
'inheritance.scss'
];
var stream;
sassFile.sourceMap = '{' +
'"version": 3,' +
'"file": "scss/subdir/multilevelimport.scss",' +
@ -372,12 +435,106 @@ describe('gulp-sass -- sync compile', function() {
'"sourcesContent": [ "@import ../inheritance;" ]' +
'}';
stream = sass.sync();
stream.on('data', function(cssFile) {
const stream = sass.sync();
stream.on('data', (cssFile) => {
should.exist(cssFile.sourceMap);
cssFile.sourceMap.sources.should.eql(expectedSources);
done();
});
stream.write(sassFile);
});
it('should work with gulp-sourcemaps and autoprefixer', (done) => {
const expectedSourcesBefore = [
'inheritance.scss',
'includes/_cats.scss',
'includes/_dogs.sass',
];
const expectedSourcesAfter = [
'includes/_cats.scss',
'includes/_dogs.sass',
'inheritance.scss',
];
gulp.src(path.join(__dirname, 'scss', 'inheritance.scss'))
.pipe(sourcemaps.init())
.pipe(sass.sync())
.pipe(tap((file) => {
should.exist(file.sourceMap);
file.sourceMap.sources.should.eql(expectedSourcesBefore);
}))
.pipe(postcss([autoprefixer()]))
.pipe(sourcemaps.write())
.pipe(gulp.dest(path.join(__dirname, 'results')))
.pipe(tap((file) => {
should.exist(file.sourceMap);
file.sourceMap.sources.should.eql(expectedSourcesAfter);
}))
.on('end', done);
});
it('should work with gulp-sourcemaps and a globbed source', (done) => {
const globPath = path.join(__dirname, 'scss', 'globbed');
const files = globule.find(path.join(__dirname, 'scss', 'globbed', '**', '*.scss'));
const filesContent = {};
files.forEach((file) => {
const source = path.normalize(path.relative(globPath, file));
filesContent[source] = fs.readFileSync(file, 'utf8');
});
gulp.src(path.join(__dirname, 'scss', 'globbed', '**', '*.scss'))
.pipe(sourcemaps.init())
.pipe(sass.sync())
.pipe(tap((file) => {
should.exist(file.sourceMap);
const actual = normaliseEOL(file.sourceMap.sourcesContent[0]);
const expected = normaliseEOL(filesContent[path.normalize(file.sourceMap.sources[0])]);
actual.should.eql(expected);
}))
.on('end', done);
});
it('should work with gulp-sourcemaps and autoprefixer with different file.base', (done) => {
const expectedSourcesBefore = [
'scss/inheritance.scss',
'scss/includes/_cats.scss',
'scss/includes/_dogs.sass',
];
const expectedSourcesAfter = [
'scss/includes/_cats.scss',
'scss/includes/_dogs.sass',
'scss/inheritance.scss',
];
gulp.src(path.join(__dirname, 'scss', 'inheritance.scss'), { base: 'test' })
.pipe(sourcemaps.init())
.pipe(sass.sync())
.pipe(tap((file) => {
should.exist(file.sourceMap);
file.sourceMap.sources.should.eql(expectedSourcesBefore);
}))
.pipe(postcss([autoprefixer()]))
.pipe(tap((file) => {
should.exist(file.sourceMap);
file.sourceMap.sources.should.eql(expectedSourcesAfter);
}))
.on('end', done);
});
it('should work with empty files', (done) => {
gulp.src(path.join(__dirname, 'scss', 'empty.scss'))
.pipe(sass.sync())
.pipe(gulp.dest(path.join(__dirname, 'results')))
.pipe(tap(() => {
try {
fs.statSync(path.join(__dirname, 'results', 'empty.css'));
} catch (e) {
should.fail(false, true, 'Empty file was produced');
}
}))
.on('end', done);
});
});

0
test/scss/empty.scss Normal file
View file

View file

@ -0,0 +1,15 @@
p {
border: 1px solid red;
}
small {
font: {
size: 72px;
}
}
h1 {
font: {
size: 8px;
}
}

View file

@ -0,0 +1,4 @@
h1, h2, h3, h4, h5 {
color: green;
font-weight: 800;
}

4555
yarn.lock Normal file

File diff suppressed because it is too large Load diff