postcss-custom-properties warnings when overriding css variables
See original GitHub issueBug Report
From Issue #7514 Related to PR #7712
Versions.
Angular CLI: 1.5.0-rc.0
Node: 8.1.2
OS: win32 x64
Angular: 5.0.0-rc.2
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
@angular/cli: 1.5.0-rc.0
@angular-devkit/build-optimizer: 0.0.25
@angular-devkit/core: 0.0.17
@angular-devkit/schematics: 0.0.30
@ngtools/json-schema: 1.1.0
@schematics/angular: 0.0.41
typescript: 2.5.3
webpack: 3.7.1
The log given by the failure.
A lot of warnings are being shown to me since #7712 :
WARNING in ./path/to/component/some-component.component.scss
(Emitted value instead of an instance of Error) postcss-custom-properties: path\to\component\some-component.component.scss: Custom property ignored: not scoped to the top-level :root element (some-css-selector { ... --custom-property: ... })
at Object.emitWarning (path-to-my-project\node_modules\webpack\lib\NormalModule.js:117:16)
at path-to-my-project\node_modules\postcss-loader\index.js:131:24
at Array.forEach (native)
at path-to-my-project\public\node_modules\postcss-loader\index.js:130:31
at <anonymous>
Repro steps.
when I set:
:root {
--custom-property: 200;
}
on styles.scss
,
and I override it in a component, some-component.scss
some-css-selector {
--custom-property: 100;
}
It’s working perfectly fine but it’s very annoying seeing a warning for each css variable I override.
May that be related to a postcss-custom-properties
limitation?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:23
- Comments:17 (1 by maintainers)
Top Results From Across the Web
postcss-custom-properties - npm
Note that these definitions will override any that exist in the CSS, and that the keys will be automatically prefixed ( -- )...
Read more >A Complete Guide to Custom Properties | CSS-Tricks
Everything important and useful to know about CSS Custom Properties. Like that they are often referred to as "CSS Variables" but that's not ......
Read more >CSS Custom Properties for Cascading Variables Module Level 1
With fallback, the component author can supply defaults, so the app author only needs to supply values for the variables they wish to...
Read more >postcss-custom-properties | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >Overwrite css variables - Stack Overflow
Use a second variable in case you want to only consider :root. :root { --new: green; } #app { --test: red; } #app...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Found a hackable workaround.
As there is no “official” way to provide Angular CLI a
postcss-custom-properties
config - yet.Open
index.js
from your projectsnode_modules\postcss-custom-properties\dist
folder Find this line:warnings: options.warnings === undefined ? true : options.warnings,
We’re going to change warnings property from
true
tofalse
.warnings: options.warnings === undefined ? false : options.warnings,
Save and run
ng serve
We need a way to add custom PostCSS config to Angular CLI projects.
This issue is related: Using the Bulma CSS library current causes lots of warnings: https://github.com/jgthms/bulma/issues/1190