Skip to content

Lazily require node-sass#748

Closed
HoldYourWaffle wants to merge 2 commits intodlmanning:masterfrom
HeldMyWaffles:lazy-node-sass
Closed

Lazily require node-sass#748
HoldYourWaffle wants to merge 2 commits intodlmanning:masterfrom
HeldMyWaffles:lazy-node-sass

Conversation

@HoldYourWaffle
Copy link
Copy Markdown

Closes #747.

Implementation of #747 for your convenience.
I'm technically in violation of the contributor guidelines by opening this PR without prior approval, but I need this functionality right now and I want to use my fork in the meantime.

I'm not sure how I should update the changelog, should I add a new version "heading"?

@ncheikh
Copy link
Copy Markdown

ncheikh commented Oct 10, 2019

Our company also would like to see this merged as it should allow for node 12 support with the node-sass dependency.

@harshjv
Copy link
Copy Markdown

harshjv commented Mar 16, 2020

@dlmanning can you please check & merge this PR?

};

// eslint-disable-next-line global-require, import/no-extraneous-dependencies
const compiler = gulpSass.compiler || require('node-sass');
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not this be auto-detection?

let compiler = gulpSass.compiler;
if (!compiler) {
  try {
    compiler = require('node-sass');
  } catch (e) {
    try {
      compiler = require('sass');
    } catch (e) {
      return cb(new PluginError(
        PLUGIN_NAME,
        "No compiler found!\nPlease install one of the npm packages: node-sass or sass, or set compiler in code:\n    const sass = require('gulp-sass');\n    sass.compiler = require('sass');\n"
      ));
    }
  }
}

So that user don't need to set dart-sass by hand. For reference, webpack's sass-loader does this kind of auto-detection.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes a lot of sense, however I'm not in a position to fix this at the moment.
I'll probably get to it somewhere next week (if nobody else has yet).

Comment on lines +16 to +18
npm install gulp-sass --save-dev
```
You must also install either `node-sass` or `sass`.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thoughts on changing this to:

You can either choose node-sass or sass:

npm install gulp-sass sass --save-dev

or:

npm install gulp-sass node-sass --save-dev

This way, users can copy the one-liner they prefer?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that makes sense. Perhaps we should also add some additional information on the differences?

@hasghari
Copy link
Copy Markdown

Can I help with anything to speed this along? Without this change, we are blocked on Node 14.

@b1rdex
Copy link
Copy Markdown

b1rdex commented Nov 10, 2020

I've just found https://www.npmjs.com/package/gulp-dart-sass that can be used as a drop-in replacement.

GregOriol added a commit to GregOriol/gulp-sass that referenced this pull request Feb 1, 2021
@xzyfer
Copy link
Copy Markdown
Collaborator

xzyfer commented Jun 15, 2021

Thanks all, close this to focus efforts on #802 which is more rounded at this point in time.

@xzyfer xzyfer closed this Jun 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lazily require node-sass

10 participants