JS support for PostCSS config

Open
#27,819 9 comments 42 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
50/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Quiet
Domain
build-system, cli

Research direction

Start at the CLI's config command and trace how JSON PostCSS configuration files are located, loaded, and passed to PostCSS. Review the existing configuration tests before deciding where JavaScript module loading belongs. Done means a JavaScript PostCSS config can be discovered and used with custom extractor functions, while existing JSON configuration still works.

Written by the indexing model from the issue text.

Description

angular/build:application area: @angular/build feature feature: under consideration
Command

config

Description

Currently the CLI supports custom PostCSS configurations in the format of JSON files. The problem is that the JSON format has its limitation. In our case for example we try to configure CSS purging with the fullhuman/postcss-purgecss plugin.

{
  "plugins": {
    "@fullhuman/postcss-purgecss": {
      "content": ["**/*.html", "**/*.ts", "**/*.js"],
      "skippedContentGlobs": ["node_modules/**"],
    }
  }
}

Unfortunately this config is not enough and therefore we would need to configure some extractors:

import purgeJs from "purgecss-from-js";
import purgeHtml from "purgecss-from-html";

const options = {
  content: [], // files to extract the selectors from
  css: [], // css
  extractors: [
    {
      extractor: purgeJs,
      extensions: ["js"],
    },
    {
      extractor: purgeHtml,
      extensions: ["html"],
    },
  ],
};
export default options;
Describe the solution you'd like

Support PostCSS configuration files writen in JavaScript.

Describe alternatives you've considered

No response

Dominant language
TypeScript
Stars
27k
Forks
11.8k
Avg merge
16h 35m
Merged PRs (30d)
176

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from angular/angular-cli

All issues in angular/angular-cli

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.