angularangular-cliangular7clean-cssangular-builder

Angular 7 - ng build --prod TypeError: Cannot read property '1' of undefined


When build my Angular project for production ng buid --prod I am getting the following error:

10% building modules 3/4 modules 1 active .../client/src/styles.sass/media/client/node_modules/clean-css/lib/optimizer/level-1/optimize.js:429 context.warnings.push('Invalid value token at ' + formatPosition(value[0][1][2][0]) + '. Ignoring.');

TypeError: Cannot read property '1' of undefined
    at optimizeBody (/media/client/node_modules/clean-css/lib/optimizer/level-1/optimize.js:429:82)
    at level1Optimize (/media/client/node_modules/clean-css/lib/optimizer/level-1/optimize.js:657:9)
    at level1Optimize (/media/client/node_modules/clean-css/lib/optimizer/level-1/optimize.js:648:9)
    at optimize (/media/client/node_modules/clean-css/lib/clean.js:144:5)
    at /media/client/node_modules/clean-css/lib/clean.js:120:29
    at /media/client/node_modules/clean-css/lib/reader/read-sources.js:26:64
    at loadOriginalSources (/media/client/node_modules/clean-css/lib/reader/load-original-sources.js:26:5)
    at /media/client/node_modules/clean-css/lib/reader/read-sources.js:26:14
    at applySourceMaps (/media/client/node_modules/clean-css/lib/reader/apply-source-maps.js:34:5)
    at /media/client/node_modules/clean-css/lib/reader/read-sources.js:25:12
    at fromStyles (/media/client/node_modules/clean-css/lib/reader/read-sources.js:152:5)
    at fromString (/media/client/node_modules/clean-css/lib/reader/read-sources.js:48:10)
    at doReadSources (/media/client/node_modules/clean-css/lib/reader/read-sources.js:33:12)
    at readSources (/media/client/node_modules/clean-css/lib/reader/read-sources.js:24:10)
    at /media/client/node_modules/clean-css/lib/clean.js:115:12
    at _combinedTickCallback (internal/process/next_tick.js:131:7)

Earlier, this day everything worked fine. But now this.

It seems to be caused by some css optimizer clean-css but I don't how how to fix it. (I tried updaing and reinstalling angular)


Solution

  • I found the issue.

    It was really silly and I don't know why I got an error when serving.

    I forgot a space in one of my .sass files

    I wrote: transform:rotate(360deg)

    But it should be: transform: rotate(360deg)