Skip to content

Commit 542aed2

Browse files
petersandordherges
authored andcommitted
fix: strip comments from processed styles (#512)
Fixes #503
1 parent d4bc66f commit 542aed2

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
"jasmine": "^2.6.0",
8888
"json-schema-to-typescript": "^5.0.0",
8989
"mocha": "^5.0.0",
90+
"postcss-discard-comments": "^2.0.4",
9091
"prettier": "^1.10.2",
9192
"pretty-quick": "^1.2.1",
9293
"react": "^16.0.0",

src/lib/steps/assets.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import * as nodeSassTildeImporter from 'node-sass-tilde-importer';
1515
import * as less from 'less';
1616
import * as stylus from 'stylus';
1717
import * as postcssUrl from 'postcss-url';
18+
import * as postcssComments from 'postcss-discard-comments';
1819

1920
export const processAssets: BuildStep =
2021
async ({ artefacts, entryPoint, pkg }): Promise<NgArtefacts> => {
@@ -85,7 +86,10 @@ const processStylesheet =
8586

8687
if (cssUrl !== CssUrl.none) {
8788
log.debug(`postcssUrl: ${cssUrl}`);
88-
postCssPlugins.push(postcssUrl({ url: cssUrl }));
89+
postCssPlugins.push(
90+
postcssUrl({ url: cssUrl }),
91+
postcssComments({ removeAll: true })
92+
);
8993
}
9094
const result: postcss.Result = await postcss(postCssPlugins)
9195
.process(cssStyles, {

yarn.lock

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1648,6 +1648,10 @@ has-ansi@^2.0.0:
16481648
dependencies:
16491649
ansi-regex "^2.0.0"
16501650

1651+
has-flag@^1.0.0:
1652+
version "1.0.0"
1653+
resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-1.0.0.tgz#9d9e793165ce017a00f00418c43f942a7b1d11fa"
1654+
16511655
has-flag@^2.0.0:
16521656
version "2.0.0"
16531657
resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-2.0.0.tgz#e8207af1cc7b30d446cc70b734b5e8be18f88d51"
@@ -1951,6 +1955,10 @@ js-base64@^2.1.8:
19511955
version "2.4.0"
19521956
resolved "https://registry.yarnpkg.com/js-base64/-/js-base64-2.4.0.tgz#9e566fee624751a1d720c966cd6226d29d4025aa"
19531957

1958+
js-base64@^2.1.9:
1959+
version "2.4.1"
1960+
resolved "https://registry.yarnpkg.com/js-base64/-/js-base64-2.4.1.tgz#e02813181cd53002888e918935467acb2910e596"
1961+
19541962
js-tokens@^3.0.0:
19551963
version "3.0.2"
19561964
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b"
@@ -2689,6 +2697,12 @@ pinkie@^2.0.0:
26892697
version "2.0.4"
26902698
resolved "https://registry.yarnpkg.com/pinkie/-/pinkie-2.0.4.tgz#72556b80cfa0d48a974e80e77248e80ed4f7f870"
26912699

2700+
postcss-discard-comments@^2.0.4:
2701+
version "2.0.4"
2702+
resolved "https://registry.yarnpkg.com/postcss-discard-comments/-/postcss-discard-comments-2.0.4.tgz#befe89fafd5b3dace5ccce51b76b81514be00e3d"
2703+
dependencies:
2704+
postcss "^5.0.14"
2705+
26922706
postcss-url@^7.3.0:
26932707
version "7.3.0"
26942708
resolved "https://registry.yarnpkg.com/postcss-url/-/postcss-url-7.3.0.tgz#cf2f45e06743cf43cfea25309f81cbc003dc783f"
@@ -2703,6 +2717,15 @@ postcss-value-parser@^3.2.3:
27032717
version "3.3.0"
27042718
resolved "https://registry.yarnpkg.com/postcss-value-parser/-/postcss-value-parser-3.3.0.tgz#87f38f9f18f774a4ab4c8a232f5c5ce8872a9d15"
27052719

2720+
postcss@^5.0.14:
2721+
version "5.2.18"
2722+
resolved "https://registry.yarnpkg.com/postcss/-/postcss-5.2.18.tgz#badfa1497d46244f6390f58b319830d9107853c5"
2723+
dependencies:
2724+
chalk "^1.1.3"
2725+
js-base64 "^2.1.9"
2726+
source-map "^0.5.6"
2727+
supports-color "^3.2.3"
2728+
27062729
postcss@^6.0.1, postcss@^6.0.14, postcss@^6.0.2:
27072730
version "6.0.14"
27082731
resolved "https://registry.yarnpkg.com/postcss/-/postcss-6.0.14.tgz#5534c72114739e75d0afcf017db853099f562885"
@@ -3399,6 +3422,12 @@ supports-color@^2.0.0:
33993422
version "2.0.0"
34003423
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7"
34013424

3425+
supports-color@^3.2.3:
3426+
version "3.2.3"
3427+
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-3.2.3.tgz#65ac0504b3954171d8a64946b2ae3cbb8a5f54f6"
3428+
dependencies:
3429+
has-flag "^1.0.0"
3430+
34023431
supports-color@^4.0.0, supports-color@^4.4.0:
34033432
version "4.5.0"
34043433
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-4.5.0.tgz#be7a0de484dec5c5cddf8b3d59125044912f635b"

0 commit comments

Comments
 (0)