Angular-cli: autoprefixer not working for serving prod builds

Created on 16 Nov 2016  路  6Comments  路  Source: angular/angular-cli

OS?

Mac OS Sierra 10.12.1

Versions.

angular-cli: 1.0.0-beta.20-4
node: 6.9.1
os: darwin x64

Repro steps.

Using SCSS:
Have a component's scss file with a prefix-able property (for instance: display: flex);

  • Running ng serve, the output will have various prefixed CSS properties for display: flex;
  • Running ng serve --prod, the output will only have the actual written display: flex, without any prefixes.

Most helpful comment

@oriolcp In order to specify browser needs concerning this, you can do all of this using a browserslist file (https://github.com/ai/browserslist).

No need to make any changes in the core this way

All 6 comments

@filipesilva, So it looks like webpack-merge doesn't handle merging LoaderOptionsPlugin. postcss is configured via the plugin in both the common webpack config and the production config.

The conflict here is between my PR #2593 and #2852.

Both creates a new instance of webpack.LoaderOptionsPlugin in the plugins array. A quickfix for now would be to simply move postcss-discard-comments into common and doing that in dev aswell. I placed it in prod only to save CPU cycles while working in dev tho.

I don't think there is any webpack plugin for merging that type of config.

I manually patch webpack-build-production.js in order to have autoprefxing on production build. I also had to add some extra params on autoprefixer because I needed to give support to Safari 7:
postcss: [autoprefixer({ browsers: ['> 1%', 'last 2 versions', 'Safari 7'] })].
I suggest to add a new setting on angular-cli.json in order to be able to change it, also we should be able to don't prefix anything if the project requeriments are just for the latest browser versions.

@oriolcp In order to specify browser needs concerning this, you can do all of this using a browserslist file (https://github.com/ai/browserslist).

No need to make any changes in the core this way

Thanks a lot I didn't know about browserslist file.

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings