aurelia / bootstrapper

Sets up the default configuration for the aurelia framework and gets you up and running quick and easy.
MIT License
75 stars 34 forks source link

Bootstrap CSS loads last and overrides custom styles #47

Closed waywardz closed 7 years ago

waywardz commented 8 years ago

I'm submitting a bug report

Please tell us about your environment:

Current behavior: Bootstrap overrides custom styles (see https://github.com/aurelia/skeleton-navigation/issues/659)

Expected/desired behavior: Resources are loaded in the order they are required.

This is a duplicate of https://github.com/aurelia/skeleton-navigation/issues/659, however, through some trial and error I believe changes in this module are the cause, and the issue occurred between aurelia-bootstrapper@1.0.0-beta.2.0.1 and aurelia-bootstrapper@1.0.0.

waywardz commented 8 years ago

I think these are also in play. I noticed when I backed down the bootstrapper it also backed down the dependencies

"aurelia-templating-binding": "npm:aurelia-templating-binding@1.0.0-beta.2.0.2", "aurelia-templating-resources": "npm:aurelia-templating-resources@1.0.0-beta.3.0.4",

EisenbergEffect commented 8 years ago

@AshleyGrant Can you look into this?

AssafDamari commented 8 years ago

Any news regarding this? We can't use any custom themes due to this issue.

EisenbergEffect commented 8 years ago

@AssafDamari As a work around, consider traditionally linking bootstrap in the head.

EisenbergEffect commented 8 years ago

@AshleyGrant Ping.

AshleyGrant commented 8 years ago

Looking in to it

AshleyGrant commented 8 years ago

So the problem looks to be that this is all "promisified," and since it takes less time to load the smaller custom css file than the larger bootstrap css file, the custom css file wins the race to be added to the DOM. We would need to make sure the promises execute in order, or depromisify the loader code.

waywardz commented 7 years ago

I took a look at 474 which is now closed, unfortunately I couldn't see jdanyow's suggestions as the links to the gitter didn't work for me.

Would it be possible to group priority loads together somehow? I don't expect to personally have more than bootstrap, but maybe an attribute that tells the loader to create one or more groups based on the priority set?

In my case I have something like this:

<require from="font-awesome/css/font-awesome.min.css"></require>
<require from="bootstrap/css/bootstrap.css"></require>
<require from="styles/css/box-selector.css"></require>
<require from="styles/css/my-style-guide.css"></require>
<require from="styles/css/jquery-ui.min.css"></require>

<require from='top-header'></require>
<require from='side-bar'></require>

my issue is that my-style-guide.css loads before bootstrap.

Would it be possible to add something like <require loadorder="1" from="bootstrap/css/bootstrap.css"></require> to indicate I want bootstrap loaded first?

waywardz commented 7 years ago

A possible workaround is to add another require with a nested require in it, allowing any overrides to be collected in one location.

in app.html

<require from='custom-css'></require>

in another file (that has an empty backing class)

<template>
    <require from="styles/css/my-style-guide.css"></require>
</template>

It looks like it loads the dependencies in groups, so it'll do the groups for app.html first, then the dependencies of custom-css.html.

plwalters commented 7 years ago

Just switch to loading Bootstrap from CDN in the head of the index.html, it's a better solution anyways.

AshleyGrant commented 7 years ago

@EisenbergEffect could we move this issue to the templating repo?

EisenbergEffect commented 7 years ago

Issue moved to aurelia/templating #514 via ZenHub