Angular6制作模式去除Bootswatch主题?

Angular 6 production mode removes Bootswatch theme?

我有一个 Angular 6 应用程序,使用 Bootstrap 4 和一个 Bootswatch 主题 (Lumen)。当我在我的测试环境中使用 ng serve 编译站点时,样式和主题工作正常,并且在使用 ng build 为我的 nginx 网络服务器编译时也工作正常。但是,当在网络服务器的生产模式 (ng build --prod) 下编译时,基本的 Bootstrap 样式可以工作,但 Bootswatch 主题显然未加载或无效。该网站看起来很普通 Bootstrap 4.

我使用 Angular CLI 的安装过程是:

npm install --save bootstrap
npm install --save @ng-boostrap/ng-bootstrap
npm install bootswatch

我的angular.json的"styles"段如下:

"styles": [
  "node_modules/bootstrap/dist/css/bootstrap.min.css",
  "node_modules/bootswatch/dist/lumen/bootstrap.min.css",
  "src/styles.css"
],

杀死我的主题的生产模式是怎么回事?我该如何解决?

编辑:我的 package.json 根据评论的要求:

{
  "name": "neo-analytics",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^6.0.3",
    "@angular/common": "^6.0.3",
    "@angular/compiler": "^6.0.3",
    "@angular/core": "^6.0.3",
    "@angular/forms": "^6.0.3",
    "@angular/http": "^6.0.3",
    "@angular/platform-browser": "^6.0.3",
    "@angular/platform-browser-dynamic": "^6.0.3",
    "@angular/router": "^6.0.3",
    "@ng-bootstrap/ng-bootstrap": "^2.1.1",
    "bootstrap": "^4.1.1",
    "bootswatch": "^4.1.1",
    "core-js": "^2.5.4",
    "rxjs": "^6.2.1",
    "rxjs-compat": "^6.2.1",
    "zone.js": "^0.8.26"
  },
  "devDependencies": {
    "@angular/compiler-cli": "^6.0.3",
    "@angular-devkit/build-angular": "~0.6.8",
    "typescript": "~2.7.2",
    "@angular/cli": "~6.0.8",
    "@angular/language-service": "^6.0.3",
    "@types/jasmine": "~2.8.6",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "codelyzer": "~4.2.1",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~1.7.1",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.0",
    "karma-jasmine": "~1.1.1",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.3.0",
    "ts-node": "~5.0.1",
    "tslint": "~5.9.1"
  }
}

不是直接在 angular.json 中的样式 [ ] 下添加,您可以尝试在 styles.css 中添加:

styles.css

@import "../node_modules/bootstrap/dist/css/bootstrap.min.css";
@import "../node_modules/bootswatch/dist/lumen/bootstrap.min.css";

angular.json

"styles": [
  "styles.css"
],

当然是:

"styles": [
   "src/styles.css"
],

我知道这是一个迟到的答案,但接受的答案是错误的。您应该用 Bootswatch 替换原来的 bootstrap.min.css。 Bootsatch 的 CSS 文件应该替换原始的 bootstrap CSS 文件。因此,在您的 angular.json 中,您只需要:

"styles": [
  "node_modules/bootswatch/dist/lumen/bootstrap.min.css",
  "src/styles.css"
],