Parcel-Angular5:如何添加 SCSS/SASS 支持?
Parcel-Angular5 : How do I add SCSS/SASS support?
我有一个使用 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
但这绝对没有产生任何变化,显然你不应该在使用 angular cli 时添加它们。
我也在用包裹。 Parcel-sass 集成很棒,但 angular-cli 可能还不支持它。 Angular-包裹很新。
我不知道。
这是我的包-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"
}
}
确保将 .angular-cli.json
中的 style.css 更改为 style.scss
据说从头开始:ng new Demo_Project --style=scss
是一个更可行的选择。虽然到目前为止我还不能把包裹送到 运行 : https://github.com/parcel-bundler/parcel/issues/757
我有一个使用 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
但这绝对没有产生任何变化,显然你不应该在使用 angular cli 时添加它们。
我也在用包裹。 Parcel-sass 集成很棒,但 angular-cli 可能还不支持它。 Angular-包裹很新。
我不知道。
这是我的包-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"
}
}
确保将 .angular-cli.json
中的 style.css 更改为 style.scss据说从头开始:ng new Demo_Project --style=scss
是一个更可行的选择。虽然到目前为止我还不能把包裹送到 运行 : https://github.com/parcel-bundler/parcel/issues/757