intoli / antd-scss-theme-plugin

A Webpack plugin for customizing Ant Design with an SCSS theme file and using Ant Design's compiled variables in SCSS files throughout your project.
https://intoli.com/blog/antd-scss-theme-plugin/
Other
202 stars 80 forks source link

Resolve absolute paths #51

Open gautier-lefebvre opened 5 years ago

gautier-lefebvre commented 5 years ago

Hello,

I have been using your plugin with sass-loader and node-sass.

node-sass has an option which allows us to specify the root folder of absolute @import paths:

{
  test: /\.scss$/i,
  loader: 'sass-loader',
  options: {
    includePaths: [
      './src/',
    ],
  },
}

includePaths is an option of node-sass and sass-loader just passes it through when compiling.

The problem is, this plugin doesn't look for this path when resolving the current imported file to decide whether or not to include the antd theme variables in src/antdSassLoader.js at line 22. It simply uses the resolver of sass-loader, not node-sass. This means that importing my antd theme file using an absolute path (e.g. @import 'style/theme.scss';) does not expose the antd theme variables.

The workaround is simply to use a relative path when importing this specific file when the antd variables are needed, but this is tedious.

Do you think adding an option to allow custom root folder, or an option to specify a resolver function overriding sass-loader's importsToResolve() would be viable for this plugin?

My best guess would be to simply consider this behaviour non standard and never use absolute paths on @import.

jeremy-cho commented 2 years ago

Any updates on this?