Issue
i am trying to apply a theme to the angular application. I think the src/theme.scss file I created is working properly by itself; but as I import the "~@angular/material/theming", there is an error:
ModuleBuildError: Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
SassError: Can't find stylesheet to import.
╷
5 │ @forward '../cdk/a11y/index.import';
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
╵
node_modules\@angular\material\_theming.scss 5:1 @use
src\theme.scss 2:1 root stylesheet
I have investigated several posts and I can't get my problem solved.
Here is my src/theme.scss :
@use "~@angular/material/theming" as mat;
@include mat-core();
$app-primary: mat.define-palette(mat.$indigo-palette, 500);
$app-accent: mat.define-palette(mat.$orange-platte, 600);
Here is the /material/_theming.scss:
// Forwards all public API mixins so they can be imported from a single entry point.
// Note that we have to forward the `.import` files for backwards-compatibility with
// projects that don't use Sass modules and include the `mat-`-prefixed mixins.
@forward '../cdk/a11y/index.import';
@forward '../cdk/overlay/index.import';
@forward '../cdk/text-field/index.import';
@forward './core/core-legacy-index';
@forward './autocomplete/autocomplete-legacy-index';
@forward './badge/badge-legacy-index';
@forward './bottom-sheet/bottom-sheet-legacy-index';
@forward './button-toggle/button-toggle-legacy-index';
@forward './button/button-legacy-index';
@forward './card/card-legacy-index';
@forward './checkbox/checkbox-legacy-index';
@forward './chips/chips-legacy-index';
@forward './datepicker/datepicker-legacy-index';
@forward './dialog/dialog-legacy-index';
@forward './divider/divider-legacy-index';
@forward './expansion/expansion-legacy-index';
@forward './form-field/form-field-legacy-index';
@forward './grid-list/grid-list-legacy-index';
@forward './icon/icon-legacy-index';
@forward './input/input-legacy-index';
@forward './list/list-legacy-index';
@forward './menu/menu-legacy-index';
@forward './paginator/paginator-legacy-index';
@forward './progress-bar/progress-bar-legacy-index';
@forward './progress-spinner/progress-spinner-legacy-index';
@forward './radio/radio-legacy-index';
@forward './select/select-legacy-index';
@forward './sidenav/sidenav-legacy-index';
@forward './slide-toggle/slide-toggle-legacy-index';
@forward './slider/slider-legacy-index';
@forward './snack-bar/snack-bar-legacy-index';
@forward './sort/sort-legacy-index';
@forward './stepper/stepper-legacy-index';
@forward './table/table-legacy-index';
@forward './tabs/tabs-legacy-index';
@forward './toolbar/toolbar-legacy-index';
@forward './tooltip/tooltip-legacy-index';
@forward './tree/tree-legacy-index';
and my angular.json:
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"TodoNg": {
"projectType": "application",
"schematics": {
"@schematics/angular:application": {
"strict": true
}
},
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/TodoNg",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.css",
"src/theme.scss"
],
"scripts": []
},
"configurations": {
"production": {
"budgets": [
{
"type": "initial",
"maximumWarning": "500kb",
"maximumError": "1mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "2kb",
"maximumError": "4kb"
}
],
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"outputHashing": "all"
},
"development": {
"buildOptimizer": false,
"optimization": false,
"vendorChunk": true,
"extractLicenses": false,
"sourceMap": true,
"namedChunks": true
}
},
"defaultConfiguration": "production"
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"configurations": {
"production": {
"browserTarget": "TodoNg:build:production"
},
"development": {
"browserTarget": "TodoNg:build:development"
}
},
"defaultConfiguration": "development"
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "TodoNg:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.spec.json",
"karmaConfig": "karma.conf.js",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.css",
"src/theme.scss"
],
"scripts": []
}
}
}
}
},
"defaultProject": "TodoNg"
}
The version of Angular I am using is 12.1.2. Any suggestion how to fix this?
Solution
I just ran into this same issue. It was a version mismatch in my package.json.
I ran an update and all of the @angular packages were versioned "^12.1.4" except @angular/cdk was "^11.x.x" changing it to "@angular/cdk": "^12.1.4"
resolved the issue.
Answered By - tuckerjt07
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.