Skip to content

SassError: Can't find stylesheet to import when it contains @forward with _index file #804

@abhiomkar

Description

@abhiomkar
  • Operating System: Mac OS
  • Node Version: v10.16.3
  • NPM Version: v6.13.4
  • webpack Version: v4.41.5
  • sass-loader Version: v8.0.2
  • dart-sass version: v1.25.0

Expected Behavior

Expected sass-loader to resolve the module when _index.scss files are used.

Actual Behavior

sass-loader throws following error when @import'ed Sass file contain @forward statement with _index file. (See reproducible steps below).

Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
SassError: Can't find stylesheet to import.

Code

See complete example here:
https://github.com/abhiomkar/sass-module-bug

How Do We Reproduce?

git clone [email protected]:abhiomkar/sass-module-bug.git
cd sass-module-bug
npm i
npx webpack

Notice the error:

[./fixture-import.scss] 434 bytes {main} [built] [failed] [1 error]

ERROR in ./fixture-import.scss
Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
SassError: Can't find stylesheet to import.
  ╷
1 │ @forward "@material/base" as mdc-base-*;
  │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  ╵
  node_modules/@material/button/_mixins.import.scss 1:1  @import
  /Users/abhiomkar/code/sass-bug-module/fixture-import.scss 1:9 

Changing webpack entry file fixture-import.scss => fixture-use.scss would fix the error.

UPDATE: See this comment for temporary workaround.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions