New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for Webpack resolve aliases #46
Comments
+1 |
Yes, It'd be helpful |
You can achieve resolve aliases except for Haven't looked into trying to get |
You can just use postcss plugin 'postcss-import' and configure it for resolving your modules in const path = require('path')
const importLoader = require('postcss-import')({
extension: '.scss', // default is '.css'
resolve: (id) => {
if (id === 'MyCSSVariables') return path.resolve(__dirname, './path/to/your/file.scss');
return id;
},
});
module.exports = {
plugins: [importLoader],
}; and then use it like that:
in every file that needs access to the variables Hope it helps! |
Is there any plan to work on this? I'd love to use this plugin over react-css-modules but I use a lot of webpack aliases. Is it possible to use the babel module resolver instead of require.resolve? If so, I could potentially use another babel-resolver plugin to set up the aliases. |
No plans to support custom resolve paths. |
bit of a terrible blocker to be honest... what's it take for a contributor to add support for this? is it feasible/possible? |
@moimikey I'd recommend switching over to using css-modules directly via the https://github.com/webpack-contrib/css-loader. It works fine with webpack aliases. |
I'd like support for this as well if possible. |
@danny-andrews went right above my head. thanks. |
+1 Is there any plan to support this? |
@gajus you wrote "No plans to support custom resolve paths". Does this just mean you don't plan to support the webpack resolve aliases (which I could totally understand), or do you even mean you don't plan to add an alias option for babel-plugin-react-css-modules on its own? |
This. Don't understand the second part of the question. |
I mean you could feature a resolve option like this for config in babelrc: Currently, I have a lot of imports like this: |
I would not support this either. Doing this is just asking for a trouble. It is perfectly normal to have multiple levels of nesting in a project. The particular example ( Besides, you can easily add the suggested feature with a separate babel plugin. It does not need to be part of |
Just add babel-plugin-module-resolver and you can easily achieve this feature. module.exports = {
...
"plugins": [
...
["module-resolver", {
"alias": {
"@": path.join(__dirname, 'src'),
}
}]
],
}; |
Is it possible to support webpack resolve aliases?
I prefer to use alias rather than have to import off relative paths.
The text was updated successfully, but these errors were encountered: