Skip to content

Sass components that reference other node packages are slow to compile #677

@bpina

Description

@bpina
  • Operating System: MacOS 10.14
  • Node Version: 10.15.0
  • NPM Version: 6.4.1
  • webpack Version: 4.21.0
  • sass-loader Version: 7.0.1

Expected Behavior / Situation

Stop searching for import files early if the import path contains a directory that doesn't exist.

Actual Behavior / Situation

Checking files to import using webpackLoader is slow when sass files reference files in other node packages. It appears that webpack is using a wide recursive search (trace) back up the file tree. This is especially painful when the file/directory doesn't exist.

Modification Proposal

When determining imports to resolve, first check if the path to includes a directory (and if that directory exists). This allows for a quicker hand off to node-sass to resolve the import.

I have a small change in place here as an experiment, which speeds up compilation for the sass packages I am using: (lines 49-53)

https://gist.github.com/bpina/a7e29cf7845799d2dd06eb19e72f1a8a

Would this be a worthwhile PR? I am not sure if the changes serve a general use case.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions