Angular 8 Universal Build Failed on SCSS Imports

I faced the same issue "ERROR in Module build failed... Can't find stylesheet to import" while running the same command to build ssr "Angular Universal". for some reason the building process is ignoring "stylePreprocessorOptions" path reference.

Solution 1:

change the @import reference to point to the files

example

@import "~src/assets/styles/apptheme";
@import "~src/assets/styles/functiontheme";

instead of

@import "apptheme";
@import "functiontheme";

Solution 2:

Open angular.json look for "server" >> "options" and add the directory reference

"stylePreprocessorOptions": {
          "includePaths": [
            "src/assets/styles"
          ]
        }

Example:

"server": {
      "builder": "@angular-devkit/build-angular:server",
      "options": {
        "outputPath": "dist/server",
        "main": "src/main.server.ts",
        "tsConfig": "tsconfig.server.json",
        "stylePreprocessorOptions": {
          "includePaths": [
            "src/assets/styles"
          ]
        }
      },....