Skip to content
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

[Bug]: Comments not getting removed from CSS #1458

Open
Daggron opened this issue Dec 7, 2022 · 1 comment
Open

[Bug]: Comments not getting removed from CSS #1458

Daggron opened this issue Dec 7, 2022 · 1 comment
Labels

Comments

@Daggron
Copy link

Daggron commented Dec 7, 2022

Describe the bug

We have added few comments in our css files but those comments are not getting removed from the build output of CSS.

PostCssConfig

// eslint-disable-next-line import/no-commonjs
module.exports = (broker) => {
  // eslint-disable-next-line import/no-dynamic-require
  const colors = require(`./src/adapters/${broker}/variables/variables`);
  return {
    plugins: [
      require('postcss-import'),
      require('postcss-custom-media')({
        importFrom: './node_modules/@smallcase/shringar/resolutions.css',
      }),
      require('postcss-mixins'),
      require('postcss-nested'),
      require('postcss-simple-vars')({
        variables: colors,
      }),
      require('postcss-flexbugs-fixes'),
      require('postcss-custom-properties')({
        importFrom: [
          './node_modules/@smallcase/shringar/variables.css',
          `./src/adapters/${broker}/variables/variables.css`,
        ],
        preserve: false,
        disableDeprecationNotice: true,
      }),
      require('cssnano')({
        preset: 'default',
      }),
     require('autoprefixer')({
        flexbox: 'no-2009',
      })
    ],
  };
};

Expected behaviour

The comments should be removed from the production build

Steps to reproduce

NA

Version

4.1.11

Preset

default

Environment

System:
    OS: macOS 13.0.1
    CPU: (8) arm64 Apple M1
    Memory: 61.06 MB / 8.00 GB
    Shell: 5.8.1 - /bin/zsh

Package details

─┬ @storybook/builder-webpack5@6.5.14
│ └─┬ css-loader@5.2.7
│   ├─┬ icss-utils@5.1.0
│   │ └── postcss@8.4.19 deduped
│   ├─┬ postcss-modules-extract-imports@3.0.0
│   │ └── postcss@8.4.19 deduped
│   ├─┬ postcss-modules-local-by-default@4.0.0
│   │ └── postcss@8.4.19 deduped
│   ├─┬ postcss-modules-scope@3.0.0
│   │ └── postcss@8.4.19 deduped
│   ├─┬ postcss-modules-values@4.0.0
│   │ └── postcss@8.4.19 deduped
│   └── postcss@8.4.19 deduped
├─┬ @storybook/manager-webpack5@6.5.14
│ └─┬ css-loader@5.2.7
│   ├─┬ icss-utils@5.1.0
│   │ └── postcss@8.4.19 deduped
│   ├─┬ postcss-modules-extract-imports@3.0.0
│   │ └── postcss@8.4.19 deduped
│   ├─┬ postcss-modules-local-by-default@4.0.0
│   │ └── postcss@8.4.19 deduped
│   ├─┬ postcss-modules-scope@3.0.0
│   │ └── postcss@8.4.19 deduped
│   ├─┬ postcss-modules-values@4.0.0
│   │ └── postcss@8.4.19 deduped
│   └── postcss@8.4.19 deduped
├─┬ @storybook/react@6.5.14
│ └─┬ @storybook/core@6.5.14
│   └─┬ @storybook/core-server@6.5.14
│     └─┬ @storybook/builder-webpack4@6.5.14
│       ├─┬ postcss-flexbugs-fixes@4.2.1
│       │ └── postcss@7.0.39 deduped
│       ├─┬ postcss-loader@4.3.0
│       │ └── postcss@7.0.39 deduped
│       └── postcss@7.0.39
├─┬ autoprefixer@9.8.8
│ └── postcss@7.0.39
├─┬ babel-plugin-react-css-modules@5.2.6
│ ├─┬ postcss-modules-extract-imports@1.2.1
│ │ └── postcss@6.0.23
│ ├─┬ postcss-modules-local-by-default@1.2.0
│ │ └── postcss@6.0.23
│ ├─┬ postcss-modules-parser@1.1.1
│ │ └── postcss@5.2.18
│ ├─┬ postcss-modules-scope@1.1.0
│ │ └── postcss@6.0.23
│ ├─┬ postcss-modules-values@1.3.0
│ │ └── postcss@6.0.23
│ ├─┬ postcss-modules@1.5.0
│ │ ├─┬ css-modules-loader-core@1.1.0
│ │ │ ├─┬ postcss-modules-extract-imports@1.1.0
│ │ │ │ └── postcss@6.0.1 deduped
│ │ │ └── postcss@6.0.1
│ │ └── postcss@7.0.39
│ └── postcss@7.0.39
├─┬ css-loader@3.6.0
│ ├─┬ icss-utils@4.1.1
│ │ └── postcss@7.0.39
│ ├─┬ postcss-modules-extract-imports@2.0.0
│ │ └── postcss@7.0.39 deduped
│ ├─┬ postcss-modules-local-by-default@3.0.3
│ │ └── postcss@7.0.39 deduped
│ ├─┬ postcss-modules-scope@2.2.0
│ │ └── postcss@7.0.39 deduped
│ ├─┬ postcss-modules-values@3.0.0
│ │ └── postcss@7.0.39 deduped
│ └── postcss@7.0.39
├─┬ cssnano@4.1.11
│ ├─┬ cssnano-preset-default@4.0.8
│ │ ├─┬ css-declaration-sorter@4.0.1
│ │ │ └── postcss@7.0.39
│ │ ├─┬ cssnano-util-raw-cache@4.0.1
│ │ │ └── postcss@7.0.39
│ │ ├─┬ postcss-calc@7.0.5
│ │ │ └── postcss@7.0.39
│ │ ├─┬ postcss-colormin@4.0.3
│ │ │ └── postcss@7.0.39
│ │ ├─┬ postcss-convert-values@4.0.1
│ │ │ └── postcss@7.0.39
│ │ ├─┬ postcss-discard-comments@4.0.2
│ │ │ └── postcss@7.0.39
│ │ ├─┬ postcss-discard-duplicates@4.0.2
│ │ │ └── postcss@7.0.39
│ │ ├─┬ postcss-discard-empty@4.0.1
│ │ │ └── postcss@7.0.39
│ │ ├─┬ postcss-discard-overridden@4.0.1
│ │ │ └── postcss@7.0.39
│ │ ├─┬ postcss-merge-longhand@4.0.11
│ │ │ ├── postcss@7.0.39
│ │ │ └─┬ stylehacks@4.0.3
│ │ │   └── postcss@7.0.39
│ │ ├─┬ postcss-merge-rules@4.0.3
│ │ │ └── postcss@7.0.39
│ │ ├─┬ postcss-minify-font-values@4.0.2
│ │ │ └── postcss@7.0.39
│ │ ├─┬ postcss-minify-gradients@4.0.2
│ │ │ └── postcss@7.0.39
│ │ ├─┬ postcss-minify-params@4.0.2
│ │ │ └── postcss@7.0.39
│ │ ├─┬ postcss-minify-selectors@4.0.2
│ │ │ └── postcss@7.0.39
│ │ ├─┬ postcss-normalize-charset@4.0.1
│ │ │ └── postcss@7.0.39
│ │ ├─┬ postcss-normalize-display-values@4.0.2
│ │ │ └── postcss@7.0.39
│ │ ├─┬ postcss-normalize-positions@4.0.2
│ │ │ └── postcss@7.0.39
│ │ ├─┬ postcss-normalize-repeat-style@4.0.2
│ │ │ └── postcss@7.0.39
│ │ ├─┬ postcss-normalize-string@4.0.2
│ │ │ └── postcss@7.0.39
│ │ ├─┬ postcss-normalize-timing-functions@4.0.2
│ │ │ └── postcss@7.0.39
│ │ ├─┬ postcss-normalize-unicode@4.0.1
│ │ │ └── postcss@7.0.39
│ │ ├─┬ postcss-normalize-url@4.0.1
│ │ │ └── postcss@7.0.39
│ │ ├─┬ postcss-normalize-whitespace@4.0.2
│ │ │ └── postcss@7.0.39
│ │ ├─┬ postcss-ordered-values@4.1.2
│ │ │ └── postcss@7.0.39
│ │ ├─┬ postcss-reduce-initial@4.0.3
│ │ │ └── postcss@7.0.39
│ │ ├─┬ postcss-reduce-transforms@4.0.2
│ │ │ └── postcss@7.0.39
│ │ ├─┬ postcss-svgo@4.0.3
│ │ │ └── postcss@7.0.39
│ │ ├─┬ postcss-unique-selectors@4.0.1
│ │ │ └── postcss@7.0.39
│ │ └── postcss@7.0.39
│ └── postcss@7.0.39
├─┬ postcss-custom-media@8.0.2
│ └── postcss@8.4.19 deduped
├─┬ postcss-custom-properties@12.1.11
│ └── postcss@8.4.19 deduped
├─┬ postcss-flexbugs-fixes@5.0.2
│ └── postcss@8.4.19 deduped
├─┬ postcss-import@14.1.0
│ └── postcss@8.4.19 deduped
├─┬ postcss-loader@6.2.1
│ └── postcss@8.4.19 deduped
├─┬ postcss-mixins@8.1.0
│ ├─┬ postcss-js@3.0.3
│ │ └── postcss@8.4.19 deduped
│ ├── postcss@8.4.19 deduped
│ └─┬ sugarss@3.0.3
│   └── postcss@8.4.19 deduped
├─┬ postcss-nested@5.0.6
│ └── postcss@8.4.19 deduped
├─┬ postcss-simple-vars@6.0.3
│ └── postcss@8.4.19 deduped
├── postcss@8.4.19
└─┬ stylelint@14.16.0
  ├─┬ @csstools/selector-specificity@2.0.2
  │ └── postcss@8.4.19 deduped
  ├─┬ postcss-safe-parser@6.0.0
  │ └── postcss@8.4.19 deduped
  └── postcss@8.4.19 deduped

Additional context

No response

@ludofischer
Copy link
Collaborator

I have noticed this issue is using cssnano 4.1.11. You could try with cssnano 5, as we don't update cssnano 4 any more. Also it would be important to have some input CSS where cssnano fails to remove the comments, since cssnano does usually remove them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants