Abdullah Rasheed
Abdullah Rasheed

Reputation: 3752

Specify order of Styles in angular-cli.json

I'm using a third party library mydatepickerrange for Angular 2. In the angular-cli-.json i'm loading the package like this:

    "packages": {
        ...
        "mydaterangepicker" :{
          "map" : "node_modules/mydaterangepicker",
          "defaultExtension": "js"
        }

I would like to load my style.css after this package in order to override it's styles. I'm unsure of how to do so, has anyone had experienced a similiar situation? Here is my present angular-cli.json below:

{
  "project": {
    "version": "1.0.0-beta.19-3",
    "name": "..."
  },
  "apps": [
    {
      "root": "src",
      "outDir": "dist",
      "assets": [
        "assets",
        "favicon.ico"
      ],
      "index": "index.html",
      "main": "main.ts",
      "test": "test.ts",
      "tsconfig": "tsconfig.json",
      "prefix": "app",
      "mobile": false,
      "styles": [
        "styles.css",
        "../node_modules/bootstrap/dist/css/bootstrap.min.css"
      ],
      "scripts": [],
      "environments": {
        "source": "environments/environment.ts",
        "dev": "environments/environment.ts",
        "prod": "environments/environment.prod.ts"
      }
    }
  ],
  "addons": [],
  "packages": {
    "moment": {
      "map": "node_modules/moment/moment.js",
      "type": "cjs",
      "defaultExtension": "js"
    },
    "mydaterangepicker" :{
      "map" : "node_modules/mydaterangepicker",
      "defaultExtension": "js"
    }
  },
  "e2e": {
    "protractor": {
      "config": "./protractor.conf.js"
    }
  },
  "test": {
    "karma": {
      "config": "./karma.conf.js"
    }
  },
  "defaults": {
    "styleExt": "css",
    "prefixInterfaces": false,
    "inline": {
      "style": false,
      "template": false
    },
    "spec": {
      "class": false,
      "component": true,
      "directive": true,
      "module": false,
      "pipe": true,
      "service": true
    }
  }
}

Upvotes: 4

Views: 5518

Answers (1)

Jim
Jim

Reputation: 61

I ran into the same issue on CLI v1.0.0-beta.26. I put the "styles.css" last in my list of files and it worked. There must be some underlying order requirement when bundling...

Upvotes: 6

Related Questions