DeloitteDigitalUK / react-redux-starter-app

Starter app with React, Redux, Webpack, CSS Modules, API calls etc.
MIT License
16 stars 0 forks source link

Extract Bootstrap styles in prod builds to ensure correct CSS load order #40

Closed michael-martin closed 7 years ago

michael-martin commented 7 years ago

What topic does this PR cover?

Bug fix:

In production builds, bootstraprc compiled its CSS into the JavaScript bundle, which then dynamically inserted that CSS into the element. This caused it to be loaded after the extracted CSS file, so Bootstrap styles overwrote the equivalent rules in our custom CSS.

In dev, this wasn't an issue because the custom CSS module files are loaded individually in the after the appended Bootstrap CSS. Only because an issue in production because in prod, those files are all concatenated into one.

Any background context you want to provide?

Fix was to ensure that in production builds, the Bootstrap CSS is part of the single compiled CSS file (Has the minor added benefit of shifting that CSS out of the JS bundle and into the CSS one, which seems sensible anyway!)