Webpack v4 and Bootstrap v4 supported!
If you're using this project and you like it, please give us a star! Thanks!
If you're building an e-commerce site, like printivity.com or a marketplace site like datacenters.com and Hawaii Chee, and you want to use Rails and React, please get in touch, as that is ShakaCode's speciality. We built those sites!
Intersted in optimizing your webpack setup for React on Rails including code splitting with react-router v4, webpack v4, and react-loadable? Contact me.
ShakaCode is currently looking to hire like-minded developers that wish to work on our projects, including Hawaii Chee. We're getting into Reason!
We at ShakaCode are a small, boutique, remote-first application development company. We fund this project by:
- Providing priority support and training for anything related to React + Webpack + Rails in our Coaching Program.
- Building custom web and mobile (React Native) applications. We typically work with a technical founder or CTO and instantly provide a full development team including designers.
- Migrating Angular + Rails to React + Rails. You can see an example of React on Rails and our work converting Angular to React on Rails at egghead.io.
- React on Rails is ShakaCode's flagship product. We want to make sure you're aware of it!
Aloha and best wishes from the ShakaCode team!
ShakaCode Community

Testimonials
From Joel Hooks, Co-Founder, Chief Nerd at egghead.io, January 30, 2017:

bootstrap-loader v3 Docs!
If you want the v1 docs which are compatible with Webpack v1, please see the v1 branch. If you're using v2, be sure to check the peer dependencies of webpack and the extract-text-webpack-plugin. See the v2 docs.
bootstrap-loader
Successor to bootstrap-sass-loader. Load Bootstrap styles and scripts in your Webpack bundle. This loader uses SASS to process CSS styles. Bootstrap 3 & 4 are supported.
Table of Contents
Installation
Get it via npm:
npm install bootstrap-loader
Don't forget to install these dependencies (use --save or --save-dev option per your needs to update your package.json):
# Bootstrap 3
npm install --save-dev bootstrap-sass
# or Bootstrap 4
npm install --save-dev bootstrap
# Node SASS & other loaders needed to handle styles
npm install --save-dev css-loader node-sass resolve-url-loader sass-loader style-loader url-loader
# Additional loaders required for Bootstrap 3 & 4
npm install --save-dev imports-loader exports-loader
If you're using Bootstrap 4, you probably need:
npm install --save-dev postcss-loader
Usage
Simply require it:
require('bootstrap-loader');
Or add bootstrap-loader as a module in an entry point in your webpack config (you'll need Webpack 2.1 beta and higher):
entry: [ 'bootstrap-loader', './app' ]
Config is optional. If used, by default it should be placed in your project's root dir with name .bootstraprc. You can write it in YAML or JSON formats. Take a look at the default config files for Bootstrap 3 and Bootstrap 4. Note, we recommend using a configuration or else you might pick up unwanted upgrades, such as when we make Bootstrap 4 the default. Config options don't fall back on the defaults once a config file is present. Be sure not to delete config options. To start with a custom config, copy over a default config file as a starting point.
If the default location doesn't work for you (e.g. you want to create multiple bootstrap configs for branding variations or you symlink your npm_modules directory), you may pass the absolute path of the .bootstraprc file to the loader in your webpack config, e.g. bootstrap-loader/lib/bootstrap.loader?extractStyles&configFilePath=${__dirname}/.bootstraprc!bootstrap-loader/no-op.js.
Note that :__dirname is a global variable that Node sets for us. It is "the name of the directory that the currently executing script resides in."
YAML Format
---
# You can use comments here
styleLoaders:
- style-loader
- css-loader
- sass-loader
styles:
normalize: true
print: true
scripts:
alert: true
button: true
JSON Format
{
// And JSON comments also!
"styleLoaders": ["style-loader", "css-loader", "sass-loader"],
"styles": {
"normalize": true,
"print": true
},
"scripts": {
"alert": true,
"button": true
}
}
If no config provided, default one for Bootstrap 3 will be used.
ENV Specific Values
The following settings can be set differently
Different settings for different environments can be used.
Example of setting production to extract styles and other envs don't and use the style-loader:
# It depends on value of NODE_ENV environment variable
env:
production:
extractStyles: true
styleLoaders:
- css-loader
- postcss-loader
- sass-loader
# If NODE_ENV specific value not found
extractStyles: false
styleLoaders:
- style-loader
- css-loader
- postcss-loader
- sass-loader
Bootstrap 4 internal dependency solution
Because of Bootstrap 4's removal of UMD, internal dependencies, such as Popover's dependencies on Tooltip and Dropdown's dependency on Utils, are no longer naively resolved by Webpack (See Issue #172. In order to solve this issue, add the following code to your webpack configuration:
plugins: [
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery",
"window.jQuery": "jquery",
Tether: "tether",
"window.Tether": "tether",
Popper: ['popper.js', 'default'],
Alert: "exports-loader?Alert!bootstrap/js/dist/alert",
Button: "exports-loader?Button!bootstrap/js/dist/button",
Carousel: "exports-loader?Carousel!bootstrap/js/dist/carousel",
Collapse: "exports-loader?Collapse!bootstrap/js/dist/collapse",
Dropdown: "exports-loader?Dropdown!bootstrap/js/dist/dropdown",
Modal: "exports-loader?Modal!bootstrap/js/dist/modal",
Popover: "exports-loader?Popover!bootstrap/js/dist/popover",
Scrollspy: "exports-loader?Scrollspy!bootstrap/js/dist/scrollspy",
Tab: "exports-loader?Tab!bootstrap/js/dist/tab",
Tooltip: "exports-loader?Tooltip!bootstrap/js/dist/tooltip",
Util: "exports-loader?Util!bootstrap/js/dist/util",
})
]
Examples
Check out example apps in examples/ folder:
Common configuration options
Here are common options for Bootstrap 3 & 4.
Bootstrap 3 & 4
loglevel
Default: disabled
Outputs debugging info. Set this option to debug to output debugging information. This is critical for debugging issues. The output will go to your webpack console.
loglevel: debug
bootstrapVersion
Default: 3
Major version of Bootstrap. Can be 3 or 4.
bootstrapVersion: 3
styleLoaders
Default: [ 'style-loader', 'css-loader', 'sass-loader' ]
Env Specific: true
Array of webpack loaders. sass-loader is required, order matters. In most cases the style loader should definitely go first and the sass loader should be last.
Note: Beginning with Webpack v2.1.0-beta.26, the '-loader' suffix is required for all loaders.
To maintain compatibility with older versions, all accepted style loaders (style, css, postcss, sass, resolve-url) are automatically appended with '-loader'.
It is recommended that you explicitly state the '-loader' suffix for every webpack loader in styleLoaders to ensure compatibility in the long term.
styleLoaders:
- style-loader
- css-loader
- sass-loader
# You can apply loader params here:
- sass-loader?outputStyle=expanded
Different settings for different environments can be used. See above example.
extractStyles
Default: false
Env Specific: true
Extract styles to stand-alone css file using mini-css-extract-plugin version 2.0.0-beta or higher. See mini-css-extract-plugin for more details.
extractStyles: false
Different settings for different environments can be used. See above example.
This param can also be set to true in webpack config:
entry: [ 'bootstrap-loader/extractStyles', './app' ]
See shakacode/react-webpack-rails-tutorial/blob/master/client/webpack.client.rails.build.config. for a working example which is deployed to www.reactrails.com.
preBootstrapCustomizations
Default: disabled
Customize Bootstrap variables that get imported before the original Bootstrap variables. Thus, derived Bootstrap variables can depend on values from here. See the Bootstrap _variables.scss file for examples of derived Bootstrap variables.
preBootstrapCustomizations: ./path/to/bootstrap/pre-customizations.scss
bootstrapCustomizations
Default: disabled