0

I have seen this and may other questions. None of the answers have solved my problem.

Below is my angular.json code. I am using angular 8.

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "angular-material": {
      "root": "",
      "sourceRoot": "src",
      "projectType": "application",
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist",
            "index": "src/index.html",
            "main": "src/main.ts",
            "tsConfig": "src/tsconfig.app.json",
            "polyfills": "src/polyfills.ts",
            "assets": [
              "src/assets",
              "src/favicon.ico"
            ],
            "stylePreprocessorOptions": {
              "includePaths": [
                "src/app/shared/scss-styles"
              ]
            },
            "styles": [
              "src/styles.scss",
              "node_modules/bootstrap/dist/css/bootstrap.min.css"
            ],
            "scripts": []
          },
          "configurations": {
            "production": {
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "extractCss": true,
              "namedChunks": false,
              "aot": true,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true,
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ]
            }
          }
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "browserTarget": "angular-material:build"
          },
          "configurations": {
            "production": {
              "browserTarget": "angular-material:build:production"
            }
          }
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "angular-material:build"
          }
        },
        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "main": "src/test.ts",
            "karmaConfig": "./karma.conf.js",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.spec.json",
            "scripts": [],
            "styles": [
              "src/styles.scss"
            ],
            "assets": [
              "src/assets",
              "src/favicon.ico"
            ]
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "src/tsconfig.app.json",
              "src/tsconfig.spec.json"
            ],
            "exclude": [
              "**/node_modules/**"
            ]
          }
        }
      }
    },
    "angular-material-e2e": {
      "root": "e2e",
      "sourceRoot": "",
      "projectType": "application",
      "architect": {
        "e2e": {
          "builder": "@angular-devkit/build-angular:protractor",
          "options": {
            "protractorConfig": "./protractor.conf.js",
            "devServerTarget": "angular-material:serve"
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "e2e/tsconfig.e2e.json"
            ],
            "exclude": [
              "**/node_modules/**"
            ]
          }
        }
      }
    }
  },
  "defaultProject": "angular-material",
  "schematics": {
    "@schematics/angular:component": {
      "prefix": "app",
      "styleext": "scss"
    },
    "@schematics/angular:directive": {
      "prefix": "app"
    }
  }
}

I have tried everything I can, from moving the "stylePreprocessorOptions" in and out of other objects to removing the src in the path. Nothing has worked. How can I make it work?

------------------------Edit : Adding more info------------------------

I am getting the error:

Can't find stylesheet to import.

@import 'shared.styles.scss'; is how I am importing my files

Inside src/app/shared/scss-styles I have one file and one folder. The file is shared.styles.scss and a folder called various-style-files that contains other .scss files that I import to shared.styles.scss.

YulePale
  • 6,688
  • 16
  • 46
  • 95
  • 1
    What is not working? Show the sass import that usnfailing and the error message. And what files do you have in scss-styles? – David Jun 28 '20 at 06:56
  • @David I have added the info you have requested. – YulePale Jun 28 '20 at 07:40
  • 1
    I tried and it works fine. Make sure you your file names and paths are correct – David Jun 28 '20 at 09:01
  • I installed node-sass. It still did not work. Then I uninstalled it. Slept. The next day it worked!!! The only thing I did different was sleep! @David thank you for trying it out. I think the problem was Vs-code or something. My code was okay. – YulePale Jun 29 '20 at 08:42
  • I am facing the same problem. Tbh i slept and its still not working. I tried all possible combinations like: - removing/adding "./" at the beginning of filepath - linking folders vs. files - adding a tilde to import nothing works – bndamm Sep 07 '20 at 12:14
  • @bndamm I understand what you are saying. Sometimes things just do not work, then they work or vice versa. It might be a vscode issue or something else completely different. Till this day I do not know what the issue was. – YulePale Sep 07 '20 at 12:34

0 Answers0