Skip to content

Commit

Permalink
Fix duplicated css imports
Browse files Browse the repository at this point in the history
  • Loading branch information
ThiefMaster authored and pferreir committed Oct 1, 2021
1 parent 3e24c82 commit 93471d2
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion webpack/base.js
Expand Up @@ -31,6 +31,18 @@ function _resolveTheme(rootPath, indicoClientPath, filePath) {
return path.resolve(rootPath, filePath);
}

function _importOnce(...args) {
// Due to https://github.com/webpack-contrib/sass-loader/pull/958/files we need to
// use a different context for the importOnce plugin in order to keep the cache
// between calls to this function.
// Using a global one might work as well but like this it's scoped with the same
// lifetime which we had before the sass-loader update as `options` is cloned at
// the same time the object previously used in `this` was created (`context` in
// `getOptions`).
this.options._ctx = this.options._ctx || {options: this.options};
return importOnce.apply(this.options._ctx, args);
}

export function getThemeEntryPoints(config, prefix) {
const themes = config.themes;
const indicoClientPath = path.join(
Expand Down Expand Up @@ -199,7 +211,7 @@ export function webpackDefaults(env, config, bundles, isPlugin = false) {
sassOptions: {
includePaths: [scssIncludePath],
outputStyle: 'compact',
importer: [sassResolver, importOnce],
importer: [sassResolver, _importOnce],
},
},
},
Expand Down

0 comments on commit 93471d2

Please sign in to comment.