question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Adding External / Global Styles e.g. Bootstrap

See original GitHub issue

Hi, Stackblitz is awesome! I’m excited to start trying it out and look forward to seeing it progress.

I have a question regarding adding styles. I normally use Sass in my Angular projects, and often pull in Bootstrap and other libraries via an @import in my style.scss file (in the top level of the src dir). This way I can also import modular styles.

// style.scss
@import "~bootstrap/dist/css/bootstrap.min.css";
@import "~font-awesome/css/font-awesome.css";
@import url('~https://fonts.googleapis.com/icon?family=Roboto');
@import "./sass/_variables.scss";
@import "./sass/_buttons.scss";
@import "./sass/_forms.scss";

I define the global stylesheet in the angular-cli.json e.g.:

// angular-cli.json
      "testTsconfig": "tsconfig.spec.json",
      "prefix": "app",
      "styles": [
        "styles.scss"
      ],
      "scripts": [],

Since we don’t have access to Angular CLI on Stackblitz, what is the best way to add in a library e.g. Bootstrap and apply the styles globally?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:5
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

9reactions
EricSimonscommented, Aug 6, 2017

Hey @jacobedawson! Thanks for the kind words 😃

Best way to do this is use the “external resources” in the dependency sidebar & link to the bootstrap css files on unpkg (https://unpkg.com/bootstrap@3.3.7/dist/css/bootstrap.min.css)

We’re looking into adding static CSS/SASS file support though, would love to hear thoughts on how you’d like to see that implemented!

3reactions
EricSimonscommented, Sep 7, 2017

@maxime1992 @jacobedawson thanks for the kind words guys! ❤️ Btw, we just shipped SASS (w/ imports from NPM) and angular-cli.json config options! You can check it out in action in the Angular starter template or my Angular Material starter template — would love hear your thoughts 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

angular-cli how to add global styles? - Stack Overflow
Copy the global styles into src/styles.css · Use CSS imports to import external rules into styles.css · Add more global styles via the...
Read more >
Angular Global CSS styles - TekTutorialsHub
There are several ways to add Global CSS styles to the Angular app. The styles can be added inline, imported in index.html or...
Read more >
Introduction - Bootstrap
Bootstrap employs a handful of important global styles and settings that you'll need to be aware of when using it, all of which...
Read more >
How to Edit, Customize, and Override Bootstrap CSS to Suit ...
If you want to customize your Bootstrap site, leave the source code as-is and simply add custom code in an external stylesheet.
Read more >
Bootstrap 4 Basics Index Page and External Style Sheet Setup
Check out our " Bootstrap 4 Make Fast Responsive Cool Websites From Scratch" course. Check it out here: http://bit.ly/BS4full-courseBootstrap ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found