Skip to content

Load config from NPM package #183

Description

@dalgard

Sharing a preset across teams or packages is a great way to reduce complexity. It surprises me that PostCSS forces me to use a postcss.config.js file rather than giving me the option to point to a shared package.

Passing a package name instead of a simple path is easy to integrate with existing options. An intuitive command line syntax might look like this:

postcss --config myPackage
postcss --config myPackage/path/to/config.js
postcss --config @myOrg/myPackage/...

Although, the preferred option would clearly be referencing it in package.json:

  "postcss": "myPackage"
  "postcss": "@myOrg/myPackage/path/to/config.js"

  "postcss": {
    "config": "@myOrg/myPackage/path/to/config.js"
  }

Prettier implements sharing configs quite beautifully with its package.json option.

To minimize friction for the user, the path string should optimally be resolved in the same way module paths are resolved in Parcel or Webpack.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions