node-sass-magic-importer icon indicating copy to clipboard operation
node-sass-magic-importer copied to clipboard

Multiple Webpack entries importing mixins fails to compile

Open christopherdarling opened this issue 6 years ago • 3 comments

We have a number of entry files A.scss and B.scss both A + B make use of a mixin called 'sass-mq' for handling breakpoints. When compiling through webpack and including this plugin the 2nd entry (B) fails due to not having the 'sass-mq' import loaded.

I presume the script is blocking the 2nd import because it was imported in the other entry file (A).

It would be great if we could choose whether to prevent multiple imports across entries or not

christopherdarling avatar Jun 01 '18 14:06 christopherdarling

Hey @christopherdarling,

you can already do this with the disableImportOnce option: https://github.com/maoberlehner/node-sass-magic-importer/tree/master/packages/node-sass-magic-importer#options :)

maoberlehner avatar Jun 01 '18 16:06 maoberlehner

hey @maoberlehner, sorry I over-simplified my example. We still want to run import-once on each entry so for example;

A.scss (@import sass-mq)
  ./modules/header.scss (@import sass-mq and others)
  ./modules/footer.scss (@import sass-mq and different others)

(3x @imports of sass-mq)

B.scss
 ./modules/other.scss (@import sass-mq and others)

(1x @import of sass-mq)

In this example, we would want @import to be imported once per-entry, so that the @import of sass-mq only gets executed once for each entry (A.scss + B.scss)

christopherdarling avatar Jun 01 '18 17:06 christopherdarling

Ah, ok I think I understand. That's tricky, I guess. But I'll think about it!

maoberlehner avatar Jun 04 '18 15:06 maoberlehner