我有一个以angular cli开始的项目。
我想用scss。
在WebStorm的终端,我输入了:
ng set defaults.styleExt scss
我将所有.css
个文件重命名为.scss
并更改了导入:
@Component({
selector: 'app-logged-in',
templateUrl: './logged-in.component.html',
styleUrls: ['./logged-in.component.scss']
})
我现在有一个奇怪的情况:解释了.scss
文件中css3规范及以下的代码,scss规范的代码不是。
前:
$fg:#00bcd4;
.topMenu{
display: flex; // <-- interpreted
background-color: $fg; // <-- not interpreted
}
我试过了:
npm i node-sass -S
npm i sass-loader -S
但是这绝对没有变化,显然你在使用角度cli时不应该添加它们。
我也在使用Parcel。 Parcel-sass集成很棒但是它可能还不支持angular-cli。 Angular-parcel很新。
我不知道。
这是我的package-json文件:
{
"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"
}
}
答案 0 :(得分:1)
确保将style.css更改为.angular-cli.json
中的style.scss从头开始说:新的Demo_Project --style = scss
是一个更可行的选择。虽然到目前为止我无法运行包裹:https://github.com/parcel-bundler/parcel/issues/757