Skip to content
This repository has been archived by the owner on Feb 18, 2022. It is now read-only.

preserve: false dosen't work with @import #204

Open
chybisov opened this issue Jan 10, 2020 · 0 comments
Open

preserve: false dosen't work with @import #204

chybisov opened this issue Jan 10, 2020 · 0 comments

Comments

@chybisov
Copy link

Hi, preserve: false dosen't work with css @import, however preserve: true works great. If index.css looks like

:root {
  --some-color: red;
}

body {
  color: var(--some-color);
}

then output will be correct

body {
  color: red;
}

If we have colors.css and index.css and import colors.css to index like this

@import 'colors.css';

body {
  color: var(--some-color);
}

then output will be

body {
  color: var(--some-color);
}

I'm using postcss-custom-properties with postcss-preset-env and webpack.

webpack.config.js

...
const loaders = [
      isEnvDevelopment && require.resolve('style-loader'),
      isEnvProduction && {
        loader: MiniCssExtractPlugin.loader,
        options: shouldUseRelativeAssetPaths ? { publicPath: '../../' } : {},
      },
      {
        loader: require.resolve('css-loader'),
        options: cssOptions,
      },
      {
        loader: require.resolve('postcss-loader'),
        options: {
          ident: 'postcss',
          plugins: () => [
            require('postcss-flexbugs-fixes'),
            require('postcss-preset-env')({
              autoprefixer: {
                flexbox: 'no-2009',
              },
              preserve: false,
              stage: 3,
            }),
            postcssNormalize(),
          ],
          sourceMap: isEnvProduction && shouldUseSourceMap,
        },
      },
    ];
...
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant