How to use the sass-loader/dist/importsToResolve function in sass-loader

To help you get started, we’ve selected a few sass-loader examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github intoli / antd-scss-theme-plugin / src / antdSassLoader.js View on Github external
export const themeImporter = (themeScssPath, contents) => (url, previousResolve, done) => {
  const request = urlToRequest(url);
  const pathsToTry = importsToResolve(request);

  const baseDirectory = path.dirname(previousResolve);
  for (let i = 0; i < pathsToTry.length; i += 1) {
    const potentialResolve = pathsToTry[i];
    if (path.resolve(baseDirectory, potentialResolve) === themeScssPath) {
      done({ contents });
      return;
    }
  }
  done();
};

sass-loader

Sass loader for webpack

MIT
Latest version published 18 days ago

Package Health Score

91 / 100
Full package analysis