Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Ability to set postcss config path #944

Closed
justinhelmer opened this issue Aug 18, 2017 · 3 comments
Closed

Ability to set postcss config path #944

justinhelmer opened this issue Aug 18, 2017 · 3 comments

Comments

@justinhelmer
Copy link

What problem does this feature solve?

lots of configs in a project (app config, webpack.base, webpack.client, webpack.server, vue-loader.config, css-loader.config, etc...) means it makes sense to have a config/ folder in the project. It's unfortunate that postcss.config.js has to remain in the root, because there is no ability to specify the path.

The postcss-loader options show a config option, that when used, allows the loader to look in a different location for postcss.config.js.

A similar functionality would be very useful for vue-loader.

What does the proposed API look like?

Another option to vue-loader:

module.exports = {
  test: /\.vue$/,
  loader: 'vue-loader',
  options: {
    // ...
    postcss: {
      config: path.resolve(__dirname, './postcss.config.js')
    }
  }
};
@LinusBorg
Copy link
Member

LinusBorg commented Aug 22, 2017

instead of providing a path, simply require the config file and pass it to vue-loader's postcss option. That works already (with a tiny bit of juggling).

const pPlugins = require('./postcss.config.js').plugins
const pOptions = Object.assign({}, require('./postcss.config.js').plugins)
delete pOptions.plugins
module.exports = {
  test: /\.vue$/,
  loader: 'vue-loader',
  options: {
    // ...
    postcss: {
      plugins: pPlugins,
      options: pOptions,
    }
  }
};

But that could be optiimized, admittedly.

@justinhelmer
Copy link
Author

Thanks a ton for finagling this; I'll use the above approach until it's baked into the loader.

@yyx990803
Copy link
Member

Close via 94d374b

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

3 participants