Angular 6 Library using bootstrap

后端 未结 6 2115
遇见更好的自我
遇见更好的自我 2021-02-19 13:14

I am creating an angular library in an angular project using angular 6 library feature https://github.com/angular/angular-cli/wiki/stories-create-library

I am creating f

6条回答
  •  别那么骄傲
    2021-02-19 13:33

    You can simply install normal bootstrap with the command below

    npm i bootstrap
    

    Then since you are using Angular 6, you will need an angular.json file anf the @angular-devkit/build-angular, not angular-cli.json. Install the devkit with the command below

    npm i @angular-devkit/build-angular --save-dev
    

    and add this line of code in the "architect" section under "build" and into "options" you need to place the style references. I have given an example below.

    "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "public",
            "index": "src/index.html",
            "main": "src/main.ts",
            "polyfills": "src/polyfills.ts",
            "preserveSymlinks": true,
            "styles": [
              "node_modules/bootstrap/dist/css/bootstrap.min.css",
              "node_modules/bootstrap/dist/css/bootstrap-theme.min.css"],
          },
          "configurations": {
            "production": {
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "extractCss": true,
              "namedChunks": false,
              "aot": false,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": false,
              "assets": [
                "src/favicon.ico",
                "src/assets"
              ],
            },
            "local": {
              "assets": [
                "src/favicon.ico"
              ]
            }
          }
        }
    

    I recommend referring to the docs on the specifics around the devkit and the angular.json configuration

提交回复
热议问题