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

Do not require postcss.config.js name when using config.path option #358

Closed
galvarez421 opened this Issue May 3, 2018 · 2 comments

Comments

Projects
None yet
3 participants
@galvarez421
Copy link

galvarez421 commented May 3, 2018

Details


Is there a reason that the config path cannot point to a module that does not have the name postcss.config.js? I created a shareable PostCSS config file with the intention to reuse it across multiple projects, and I assumed that if I pointed to this file using the config.path then the file would work regardless of it name. I certainly don't mind renaming the config file in my shareable config package to postcss.config.js, but I thought I would ask if this naming convention is necessary in a case where the path to the config file is explicit. Loosening this convention would also seem to allow for the possibility of multiple shareable PostCSS configs in a single package (see https://eslint.org/docs/developer-guide/shareable-configs#sharing-multiple-configs for an example).

Error Log


From Webpack output:

Module build failed: Error: No PostCSS Config found in: C:\myproject\node_modules\my-shareable-postcss-config\index.js

Reproduction [Code]


In Webpack config:

{
  loader: 'postcss-loader',
  options: {
    config: {
      path: path.resolve(__dirname, 'node_modules/my-shareable-postcss-config/index.js'),
    },
    sourceMap: true,
  },
},

Environment


Please provide information about your environment.

OS node npm postcss-loader
Windows 7 Enterprise 8.94 4.6.1 2.1.4
@evilebottnawi

This comment has been minimized.

Copy link
Collaborator

evilebottnawi commented May 3, 2018

@galvarez421 looks like bug inside postcss-load-config package
Feel free investigate and send PR 👍

@michael-ciniawsky

This comment has been minimized.

Copy link
Collaborator

michael-ciniawsky commented May 4, 2018

The name is an hardcoded requirement of cosmiconfig and 'enforces' are convention which is intended. You are revering to extends within eslintrc configs which isn't currently supported by postcss.config.js directly. A postcss.config.js file is scoped to the project, but you may require() a preset shared through an node module as follows

postcss.config.js

module.exports = require('my-preset')(options)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment