intoli/antd-scss-theme-plugin

Resolve absolute paths

gautier-lefebvre opened this issue · 1 comments

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.

Any updates on this?