maoberlehner / node-sass-magic-importer

Custom node-sass importer for selector specific imports, module importing, globbing support and importing files only once.
MIT License
292 stars 28 forks source link

Multiple Webpack entries importing mixins fails to compile #172

Open christopherdarling opened 6 years ago

christopherdarling commented 6 years ago

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

maoberlehner commented 6 years ago

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 :)

christopherdarling commented 6 years ago

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)

maoberlehner commented 6 years ago

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