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

Used md5 to import scss/css files exactly one time based on their con… #216

Closed mansoor-omrani closed 1 year ago

mansoor-omrani commented 4 years ago

Hi

I propose to use md5 generation for importing scss/css file content, instead of just add their URI to nodeSassOnceImporterContext.store.

By creating md5 for content of files that are being imported, we can better make sure that files are imported only once.

I used nodejs-md5 library to generate md5, but any other md5 library can satisfy this need.

Since the API of nodejs-md5 is async, I needed to tamper index.ts a little (added a third callback argument to importer() function), so that it also works asynchronously.

I also propose to use nodeSassOnceImporterContext as an outer variable, instead of using it on 'this'. IMHO this better guarantees that the variable is assigned only once.