Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use 'loadPaths' instead of 'includePaths' for Sass #18

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ module.exports = {

#### Choose the Sass compiler

For backwards-compatibility reasons, the default compiler is LibSass via node-sass, [which has been deprecated by the Sass project](https://sass-lang.com/blog/libsass-is-deprecated). You can pick the canonical implementation (Dart Sass) by setting `sassCompiler` on the `styles` object in `gulp-config.js`. You will need to install the Dart Sass Node package via npm or yarn (`npm install sass` or `yarn add sass`).
For backwards-compatibility reasons, the default compiler is LibSass via node-sass, [which has been deprecated by the Sass project](https://sass-lang.com/blog/libsass-is-deprecated). You can pick the canonical implementation (Dart Sass) by setting `sassCompiler` on the `styles` object in `gulp-config.js`. You will need to install the Dart Sass Node package via npm or yarn (`npm install sass-embedded` or `yarn add sass-embedded`).

Example (excerpt from `gulp-config.js`):

Expand All @@ -119,7 +119,7 @@ styles: {
files: [
],
sassCompiler: 'sass', // this passes Dart Sass to gulp-sass
sassCompiler: 'sass-embedded', // this is an official version of Dart Sass, optimized for embedded use in NodeJS (faster compile times)
postCssPlugins: postCssPlugins,
watch: ['src/**/*.scss']
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "webfactory-gulp-preset",
"version": "2.5.1",
"version": "2.5.2",
"dependencies": {
"@babel/core": "^7.13.8",
"@babel/preset-env": "^7.13.8",
Expand Down
20 changes: 14 additions & 6 deletions tasks/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,22 @@ function styles(gulp, $, config) {
return;
}

const sassIncludePaths = config.styles.includePaths ? config.styles.includePaths : [config.npmdir];
let sassConfig = {
cwd: config.webdir,
pipeStdout: true,
sassOutputStyle: 'nested',
};

if (!config.styles.sassCompiler || config.styles.sassCompiler !== "node-sass") {
sassConfig.loadPaths = sassIncludePaths;
} else {
sassConfig.includePaths = sassIncludePaths;
}

return gulp.src(sourceFiles, { cwd: config.webdir })
.pipe(config.development ? $.sourcemaps.init() : $.through2.obj())
.pipe($.sass({
cwd: config.webdir,
pipeStdout: true,
sassOutputStyle: 'nested',
includePaths: config.styles.includePaths ? config.styles.includePaths : [config.npmdir]
}).on('error', $.sass.logError))
.pipe($.sass(sassConfig).on('error', $.sass.logError))
.pipe($.postcss(config.styles.postCssPlugins(config, stylesheet)))
.pipe($.concat(stylesheet.name))
.pipe($.cleanCss({
Expand Down