【发布时间】:2022-05-05 00:14:24
【问题描述】:
我的公司正在进行品牌重塑,这涉及到我们的应用程序的一些颜色更改。 其中大部分只是调整 SCSS 变量,但我希望能够使用“主题切换器”演示应用程序,在这里我可以在 2 个样式表之间切换。
我两次构建了应用程序 - 一次使用旧的 SCSS 变量,一次使用新的。但是,在两个样式表之间切换时,由于<head> 中嵌入了样式,更改并没有完全体现出来
我搜索了很多,似乎没有其他人问这个问题。有谁知道如何摆脱这些并将它们包含在样式表中(在构建期间使用--extract-css),甚至为什么将某些样式提取到样式表中以及为什么某些样式包含在嵌入样式中?
如果需要,我的 angular.json 的相关部分如下。
"projects": {
"cd": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"prefix": "app",
"schematics": {
"@schematics/angular:component": {
"styleext": "scss"
}
},
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/cd",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.app.json",
"assets": ["src/favicon.ico", "src/assets"],
"styles": [
"src/styles.scss",
{
// I put this in here thinking I could re-declare all the color variables in newtheme.scss and when the bundle was created it would rewrite all of the styles that used those variables too. No dice.
"input": "src/assets/css/newtheme.scss",
"bundleName": "newtheme",
"inject": false
}
],
"stylePreprocessorOptions": {
"includePaths": ["src/assets/css"]
},
"scripts": []
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
}
]
},
【问题讨论】:
-
只是好奇什么嵌入式头部样式?
-
@JohnPeters 在我的 中,我有大约 35 个
标签: angular sass angular-cli