clean-css: BUG: Cannot read property '0' of undefined
Environment
- clean-css version -
4.2.0
: - node.js version -
10.7.0
: - operating system: Mac High Sierra
Configuration options
Angular CLI 6.1.2, Angular 6.1.1
Error
The error is hidden because the error reporting code fails. looks to be an invalid animation issue in my 3rd party SCSS but I am not sure what it is. I will look deeper into my CSS but line break-up.js:566 needs fixing.
asset optimization node_modules/clean-css/lib/optimizer/level-2/properties/populate-components.js:30 throw e; ^
TypeError: Cannot read property ‘0’ of undefined at transition (./node_modules/clean-css/lib/optimizer/level-2/break-up.js:566:93) at Object.breakUp (./node_modules/clean-css/lib/optimizer/level-2/break-up.js:466:28) at populateComponents (./node_modules/clean-css/lib/optimizer/level-2/properties/populate-components.js:17:42) at optimizeProperties (./node_modules/clean-css/lib/optimizer/level-2/properties/optimize.js:19:3) at recursivelyOptimizeProperties (/Users/crash/git/traveliko/traveliko-spa/node_modules/clean-css/lib/optimizer/level-2/optimize.js:63:9) at recursivelyOptimizeProperties (./node_modules/clean-css/lib/optimizer/level-2/optimize.js:66:9)
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 29
@bjornharvold I got it to work when I set “extractCss” to false
“extractCss”: false,
Hi, please upgrade and fix this issue. At “node_modules@angular-devkit\build-angular\node_modules\clean-css\lib\optimizer\level-2\break-up.js:566:93”
throw new InvalidPropertyError('Invalid animation value at ' + formatPosition(value[2][0]) + '. Ignoring.');
[0] is undefined so throwing exception is also throwing exception, LOL. And I am getting this error at bootstrap.css process.
So this happened to me when I was trying to minify using and I’m not using an Angular stack:
transition: 500ms flex-basis ease-in-out;
Same happens with any flex property from as far as I could tell.
The couple fixes that I found was from @spiderpig and @lilcoder . However, I want all of the optimizations running if I can do so, and it seems to be possible. @umutcakirbm had directed me towards the correct path and there are probably multiple solutions to fix this particular issue. Without digging further and really understanding what’s going on under the hood I found that adding an additional if statement in the break-up.js file in clean-css\lib\optimizer\level-2 works well:
break-up.js in function transition(property, compactable, validator) starting on line 553
Change this block to:
I’m sure there is a better way to mitigate the thrown error but to always check if the value[2] is defined before throwing the InvalidPropertyError is a start. Again, without a deep dive I’m not sure if this breaks other things but then the transition property works accordingly. I’d submit a merge request but I’m thinking this isn’t the best solution out there.
Can you say that again in Angular CLI speak 😉