Skip to content

Commit 499ef2f

Browse files
clydinhansl
authored andcommitted
feat(build): minify/optimize component stylesheets (#4259)
1 parent 335ab5f commit 499ef2f

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"chalk": "^1.1.3",
4949
"common-tags": "^1.3.1",
5050
"css-loader": "^0.26.1",
51+
"cssnano": "^3.10.0",
5152
"debug": "^2.1.3",
5253
"denodeify": "^1.2.1",
5354
"diff": "^2.2.2",
@@ -81,7 +82,6 @@
8182
"opn": "4.0.1",
8283
"ora": "^0.2.0",
8384
"portfinder": "1.0.9",
84-
"postcss-discard-comments": "^2.0.4",
8585
"postcss-loader": "^0.9.1",
8686
"raw-loader": "^0.5.1",
8787
"reflect-metadata": "^0.1.8",

packages/angular-cli/models/webpack-configs/production.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ export const getProdConfig = function (wco: WebpackConfigOptions) {
1313
new webpack.DefinePlugin({
1414
'process.env.NODE_ENV': JSON.stringify('production')
1515
}),
16-
new webpack.LoaderOptionsPlugin({ minimize: true }),
1716
new webpack.optimize.UglifyJsPlugin(<any>{
1817
mangle: { screw_ie8: true },
1918
compress: { screw_ie8: true, warnings: buildOptions.verbose },

packages/angular-cli/models/webpack-configs/styles.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
import { extraEntryParser, getOutputHashFormat } from './utils';
77
import { WebpackConfigOptions } from '../webpack-config';
88

9-
const postcssDiscardComments = require('postcss-discard-comments');
9+
const cssnano = require('cssnano');
1010
const autoprefixer = require('autoprefixer');
1111
const ExtractTextPlugin = require('extract-text-webpack-plugin');
1212

@@ -38,9 +38,10 @@ export function getStylesConfig(wco: WebpackConfigOptions) {
3838
// https://github.com/webpack-contrib/style-loader#recommended-configuration
3939
const cssSourceMap = buildOptions.extractCss && buildOptions.sourcemap;
4040

41-
// discard comments in production
41+
// minify/optimize css in production
42+
// autoprefixer is always run separately so disable here
4243
const extraPostCssPlugins = buildOptions.target === 'production'
43-
? [postcssDiscardComments]
44+
? [cssnano({ safe: true, autoprefixer: false })]
4445
: [];
4546

4647
// determine hashing format

packages/angular-cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"chalk": "^1.1.3",
3939
"common-tags": "^1.3.1",
4040
"css-loader": "^0.26.1",
41+
"cssnano": "^3.10.0",
4142
"debug": "^2.1.3",
4243
"denodeify": "^1.2.1",
4344
"diff": "^2.2.2",
@@ -68,7 +69,6 @@
6869
"opn": "4.0.1",
6970
"ora": "^0.2.0",
7071
"portfinder": "1.0.9",
71-
"postcss-discard-comments": "^2.0.4",
7272
"postcss-loader": "^0.9.1",
7373
"raw-loader": "^0.5.1",
7474
"remap-istanbul": "^0.6.4",

0 commit comments

Comments
 (0)