question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Syntax Error: SassError: This file is already being loaded. With additionalData.

See original GitHub issue

I create a new issue with the repo as recommend in the #908 issue.

  • Operating System: macOS 11.2.3 (I think this isn’t important)
  • Node Version: v14.15.4
  • NPM Version: 6.14.10
  • webpack Version: 4.46.0
  • sass-loader Version: from 9.0.0

For version less than 9.0.0, which uses prependData, everything works fine.

Expected Behavior

additionalData should work like prependData.

Actual Behavior

additionalData causes compile error.

Code

 error  in ./src/scss/_problem.scss

Syntax Error: SassError: This file is already being loaded.
  ╷
1 │ @import "problem";
  │         ^^^^^^^^^
  ╵
  src/scss/_module.scss 1:9    @import
  src/scss/_problem.scss 2:19  root stylesheet

How Do We Reproduce?

Use this repo.

  1. Clone. Run npm i.
  2. Run npm run serve.
  3. See error in console.

Webpack settings you can find in vue.config.js

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

7reactions
alexander-akaitcommented, May 18, 2021

You can’t import the same file twice, if you need more information you can look at docs for sass and read about import, other solutions is migrate on @use

0reactions
alexander-akaitcommented, May 18, 2021

You can exclude import for specific file, using:

additionalData: (content, loaderContext) => {
          if (loaderContext.resourcePath.endsWith('src/scss/_problem.scss')) {
            return content;
          }
          
          return `
          @import "~@/scss/_module.scss";
          ${content}
        `;
        }
Read more comments on GitHub >

github_iconTop Results From Across the Web

I get "SassError: This file is already being loaded." because I ...
I get "SassError: This file is already being loaded. ... use variables that I already imported globally in config's additionalData... so how ...
Read more >
SassError: This file is already being loaded. @import '~src/css ...
I am using the quasar framework and while compiling the project I'm getting the above error. Module ...
Read more >
A brand new website interface for an even better experience!
Syntax Error : SassError: This file is already being loaded. With additionalData.
Read more >
Fix for `SassError: This file is already being loaded.` - StackBlitz
error about the file being loaded twice. One solution is to move the color definitions. from `app.
Read more >
Error when importing scss file - Get Help - Vue Forum
Syntax Error : SassError: expected “;” I want variables.scss to be recognized and used in a folder root (assets/scss) other than the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found