angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

3rd party libs not being pulled into global css or js

Open jspenc72 opened this issue 10 years ago • 11 comments

Please provide us with the following information:

  1. OS? Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?) Mac OSX El Capitan
  1. Versions. Please run ng --version. If there's nothing outputted, please run in a Terminal: node --version and paste the result here:
$ ng --version
Could not start watchman; falling back to NodeWatcher for file system events.
Visit http://ember-cli.com/user-guide/#watchman for more info.
angular-cli: 1.0.0-beta.11-webpack.2
node: 4.2.2
os: darwin x64
$ 
  1. Repro steps. Was this an app that wasn't created using the CLI? What change did you do on your code? etc.
  2. Create new project with angular-cli@webpack
  3. The log given by the failure. Normally this include a stack trace and some more information. no errors are output
  4. Mention any other details that might be useful.

{
  "project": {
    "version": "1.0.0-beta.11-webpack.2",
    "name": "ready-med"
  },
  "apps": [
    {
      "main": "src/main.ts",
      "tsconfig": "src/tsconfig.json",
      "mobile": false,
      "styles" : [
        "styles.scss",
        "../node_modules/bootstrap/dist/css/bootstrap.css"
      ],
      "scripts" : [
        "../node_modules/jquery/dist/jquery.js",
        "../node_modules/tether/dist/js/tether.js",
        "../node_modules/bootstrap/dist/js/bootstrap.js"        
      ]
    }
  ],
  "addons": [],
  "packages": [],
  "e2e": {
    "protractor": {
      "config": "config/protractor.conf.js"
    }
  },
  "test": {
    "karma": {
      "config": "config/karma.conf.js"
    }
  },
  "defaults": {
    "prefix": "app",
    "sourceDir": "src",
    "styleExt": "scss",
    "prefixInterfaces": false,
    "lazyRoutePrefix": "+"
  }
}


Thanks! We'll be in touch soon.

jspenc72 avatar Sep 09 '16 20:09 jspenc72

update angular-cli this issue is fixed in 1.0.0-beta.11-webpack.8

aszechlicki avatar Sep 10 '16 10:09 aszechlicki

Updating resolved the issue

jspenc72 avatar Sep 10 '16 19:09 jspenc72

Thank you!

jspenc72 avatar Sep 10 '16 19:09 jspenc72

It isn't working for me using latest update. At least bootstrap isn't. I will check again tomorrow but I am pretty sure I used latest version and performed same steps op did. I used npm version of bootstrap.

jjhidalgar avatar Sep 10 '16 20:09 jjhidalgar

@jaimehrubiks double-check paths, I lost a lot of time before I noticed that I had mine wrong paths in global scripts and styles are relative to your apps[0].root directory

unfortunately, angular-cli doesn't give any error/warning if it cannot find specified files

aszechlicki avatar Sep 10 '16 20:09 aszechlicki

What OS do you use? Yesterday, I also noticed something strange in term of using angular-cli.

On Windows 7, I used a cli config file like you (in terms of the bootstrap path in the styles property) and worked fine. If I use the exact same file in a linux environment, it didn't worked. The build was succesfull, but the css file was not included in the bundle. What I did is that I placed the bootstrap path as an import in the global styles.css like below: @import '../node_modules/bootstrap/dist/css/bootstrap.css';

After this change, it worked fine on both environments, so it seems to be that there is some different behaviour in terms of OS. I am also not sure what the difference is between the property styles and the global styles.css. Should external stylesheets from a different package be loaded using the global styles.css, using the cli config file or both should be supported?

ewoutreinders avatar Sep 11 '16 12:09 ewoutreinders

global styles.css file is meant for your custom css that you want applied to the whole application
styles in apps[0].styles are third-party styles that you want to load

aszechlicki avatar Sep 11 '16 13:09 aszechlicki

@jaimehrubiks try generating a new project with ng new Then verify that the angular-cli.json have webpack 8 in the version.

jspenc72 avatar Sep 11 '16 18:09 jspenc72

It is working.

My problem seems to be related to bootstrap, somehow it does not work correctly when following the guide on this repo (on osx). But I downloaded it manually (instead of npm) and put it on assets folder and linked on styles[0] and it works perfect.

jjhidalgar avatar Sep 12 '16 23:09 jjhidalgar

This functionality was only present starting 1.0.0-beta.11-webpack.8. The current latest 1.0.0-beta.14 also fully supports this.

filipesilva avatar Sep 20 '16 02:09 filipesilva

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.