stencil-community / stencil-postcss

Autoprefixer plugin for Stencil
https://www.npmjs.com/package/@stencil-community/postcss
Other
30 stars 24 forks source link

PostCSS plugins mutate input CSS #34

Closed bradlc closed 1 year ago

bradlc commented 3 years ago

The output of a PostCSS compilation is fed back into subsequent runs as the input. You can see this by creating a simple plugin:

import { Config } from '@stencil/core';
import { postcss } from '@stencil/postcss';

export const config: Config = {
  // ...
  plugins: [
    postcss({
      plugins: [
        root => {
          console.log(root.toString());
          root.nodes = [require('postcss').comment({ text: 'This should not be logged' })];
          return root;
        },
      ],
    }),
  ],
};

The result of this compilation is /* This should not be logged */, and on subsequent runs this enters the plugin as the input.

Reproduction: https://github.com/bradlc/stencil-postcss-bug

  1. npm install
  2. npm start
  3. Open src/components/app-home/app-home.tsx and comment out line 5 (styleUrl: 'app-home.css',)
  4. Save the file
  5. Uncomment line 5
  6. Save the file
  7. Notice that /* This should not be logged */ is logged to the console

Expected result: the input should always be the contents of the actual CSS file from disk.

splitinfinities commented 2 years ago

Hey there, thank you for the patience getting back to you. The new team is getting started and we're working through the backlog now. I'm going to mark this as needs validation for a moment while I work on the remainder of the issues noted in this repo.

dtaalbers commented 2 years ago

@splitinfinities by chance, do you any updates on this?