tatsu
tatsu

Reputation: 2536

Parcel-Angular5 : How do I add SCSS/SASS support?

I have a project started with angular cli.

I want to use scss.

In WebStorm's terminal, I typed :

ng set defaults.styleExt scss

I renamed all the .css files to .scss and changed the imports :

@Component({
  selector: 'app-logged-in',
  templateUrl: './logged-in.component.html',
  styleUrls: ['./logged-in.component.scss']
})

I have a bizarre situation now: the code in that .scss file that is css3 norm and below is interpreted and code that is scss norm is not.

Ex :

$fg:#00bcd4;

.topMenu{
  display: flex; // <-- interpreted
  background-color: $fg; // <-- not interpreted
}

I tried :

npm i node-sass -S
npm i sass-loader -S

but this yielded absolutely no change and apparently you're not supposed to add them when using angular cli.

I'm also using Parcel. Parcel-sass integration is great but it may not be supported with angular-cli yet. Angular-parcel is quite new.

I don't know.

here's my package-json file :

{
  "name": "web.ui",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "parcel": "parcel",
    "start": "parcel ./src/index.html --no-cache",
    "build": "parcel build ./src/index.html  --no-cache"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^5.0.0",
    "@angular/common": "^5.0.0",
    "@angular/compiler": "^5.0.0",
    "@angular/core": "^5.0.0",
    "@angular/forms": "^5.0.0",
    "@angular/http": "^5.0.0",
    "@angular/platform-browser": "^5.0.0",
    "@angular/platform-browser-dynamic": "^5.0.0",
    "@angular/router": "^5.0.0",
    "core-js": "^2.4.1",
    "parcel-plugin-inlinesvg": "0.0.12",
    "rxjs": "^5.5.2",
    "zone.js": "^0.8.14"
  },
  "devDependencies": {
    "@angular/cli": "1.6.6",
    "@angular/compiler-cli": "^5.0.0",
    "@angular/language-service": "^5.0.0",
    "@types/jasmine": "~2.5.53",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "~6.0.60",
    "codelyzer": "^4.0.1",
    "eslint": "4.16.0",
    "eslint-config-prettier": "2.9.0",
    "eslint-plugin-prettier": "2.6.0",
    "jasmine-core": "~2.6.2",
    "jasmine-spec-reporter": "~4.1.0",
    "karma": "~1.7.0",
    "karma-chrome-launcher": "~2.1.1",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^1.2.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "parcel-bundler": "^1.2.0",
    "parcel-plugin-eslint": "^1.0.3",
    "parcel-plugin-typescript": "0.2.0-angular.0",
    "postcss-modules": "^1.1.0",
    "prettier": "1.10.2",
    "protractor": "~5.1.2",
    "ts-node": "~3.2.0",
    "tslint": "~5.7.0",
    "typescript": "~2.4.2"
  }
}

Upvotes: 0

Views: 1112

Answers (1)

tatsu
tatsu

Reputation: 2536

make sure you change the style.css to style.scss in .angular-cli.json

that being said starting from scratch : ng new Demo_Project --style=scss

is a more viable option. although so far I cannot get parcel to run : https://github.com/parcel-bundler/parcel/issues/757

Upvotes: 1

Related Questions