postcss / postcss-load-config

Autoload Config for PostCSS
MIT License
642 stars 72 forks source link

Use webpacks resolve.modules #188

Closed felixoi closed 3 years ago

felixoi commented 5 years ago

I am having a setup where the nodejs modules are installed in a different directory. This ends up in using a relative path like

require(Path.resolve(__dirname, "target/scala-2.12/scalajs-bundler/main/node_modules/autoprefixer"))

which is totally stupid since I have to staticly bind a dynamically changing folder. The problem with this is that the postcss.config.js is sometimes called from different base directories, so __dirname changes which ends up in modules are not found. This would be fixes when using the resolve.modules property from webpack since it always has the same base. In my case it's configured like

resolve.modules: [
            Path.resolve(__dirname, 'node_modules')
]

With this I could just do require('autoprefixer') and it would automatically use the configured directory to find the node modules. Since most postcss plugins are nodejs modules it would be very helpful.

felixoi commented 5 years ago

Actually works when using this config and not require:

module.exports = {
    plugins: {
        'autoprefixer': true
    }
};
michael-ciniawsky commented 3 years ago

@felixoi I not 100% sure I get want you are trying to achieve here and since the issue seems to be fixed when using 'plugin object notation' can this issue be closed?

felixoi commented 3 years ago

Yes, sorry. Forgot this one.