GithubHelp home page GithubHelp logo

shakacode / bootstrap-loader Goto Github PK

View Code? Open in Web Editor NEW
1.0K 42.0 487.0 1.31 MB

Load Bootstrap styles and scripts in your Webpack bundle

License: MIT License

JavaScript 99.49% Shell 0.51%
bootstrap-loader bootstrap-variables shakacode bootstrap-mixins bootstrap-styles webpack2 webpack-loader twitter-bootstrap webpack sass-loader

bootstrap-loader's Introduction

Build Status npm version

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

2017-01-31_14-16-56

Testimonials

From Joel Hooks, Co-Founder, Chief Nerd at egghead.io, January 30, 2017: 2017-01-30_11-33-59

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

This gets loaded after bootstrap variables is loaded. Thus, you may customize Bootstrap variables based on the values established in the Bootstrap _variables.scss file. Note, if bootstrap did not have derived values, it would not be necessary to have two config files for customizing bootstrap values.

If you want your bootstrap override value to apply to derived variable values, then place your customizations in preBootstrapCustomizations. If you want to be sure your changes don't affect other derived values, place the changes in bootstrapCustomizations.

If you are not sure, you can probably simply use preBootstrapCustomizations and, if you have issues, see _variables.scss for derived values.

bootstrapCustomizations: ./path/to/bootstrap/customizations.scss

appStyles

Default: disabled

Import your custom styles here. Usually this endpoint-file contains list of @imports of your application styles.

appStyles: ./path/to/your/app/styles/endpoint.scss

styles

Default: all

Bootstrap styles.

styles:
  mixins: true
  normalize: true
  ...

# or enable/disable all of them:
styles: true / false

scripts

Default: all

Bootstrap scripts.

scripts:
  transition: true
  alert: true
  ...

# or enable/disable all of them:
scripts: true / false

useCustomIconFontPath

Default: false

If you're using a custom icon font and you need to specify its path ($icon-font-path) in your Sass files, set this option to true.

useCustomIconFontPath: true / false
$icon-font-path: ../fonts // relative to your Sass file
$icon-font-name: 'glyphicons' // you'll typically want to change this too.

Bootstrap 4 only

There is only one additional option for Bootstrap 4:

Tether

Additionally, Bootstrap 4 requires Tether. You can add Tether per the examples in the /examples directory.

  1. Add tether to package.json: npm i --save tether
  2. Add tether as an entry point to your webpack config.
  3. Add this plugin to your webpack config:
  plugins: [
    new ExtractTextPlugin('app.css', { allChunks: true }),
    new webpack.ProvidePlugin({
      "window.Tether": "tether"
    }),
  ],

PostCSS

Bootstrap 4 seems to require postcss:

  1. Add postcss and the the postcss-loader: npm i --save postcss postcss-loader
  2. Put postcss before sass in the order of loaders in your .bootstraprc file.

Glyphicon alternatives

Glyphicons have been removed from Bootstrap 4. The examples demonstrate how to use the font-awesome-loader

Additional configurations

Paths to custom assets

If you use bootstrap-loader to load your styles (via preBootstrapCustomizations, bootstrapCustomizations & appStyles) and you load custom assets (fonts, images etc.), then you can use relative paths inside url method (relative to SASS file, from which you load asset).

This was made possible thanks to resolve-url-loader. In common case you don't have to do anything special to apply it โ€” we are doing it internally (just don't forget to install it). But if you want to use its custom settings, please provide it explicitly via styleLoaders option in .bootstraprc:

styleLoaders:
  - style-loader
  - css-loader?sourceMap
  - resolve-url-loader?sourceMap
  - sass-loader?sourceMap

Incorporating Bootswatch themes

The following steps are needed to successfully incorporate a theme from Bootswatch:

  1. Download the .scss files (_variables.scss and _bootswatch.scss) for the theme you have chosen.

  2. Put the files somewhere in your project structure (e.g. the ./styles directory).

  3. Add an additional SCSS file, like bs-theme.scss, that contains the following:

    @import './_bootswatch.scss';
    
  4. Add the following to your .bootstraprc file:

preBootstrapCustomizations: ./styles/_variables.scss
appStyles: ./styles/bs-theme.scss

The theme should now be applied as expected. Note that this section might be valid for other theme packs as well.

Multiple CSS themes

See examples/multiple-entries/webpack.prod.config.js for an example configuration of the following:

  1. In entry, set up one bundle per theme. In each bundle include bootstrap-loader with extractStyles and the respective config file.
  2. In plugins, set up the extract-text-webpack-plugin to output each CSS file as [name].css. This will output a CSS file named after each bundle.

jQuery

If you want to use Bootstrap's JS scripts โ€” you have to provide jQuery to Bootstrap JS modules using imports-loader. To avoid having to include jQuery in your project you can disable all scripts (see scripts).

module: {
  loaders: [
    // Use one of these to serve jQuery for Bootstrap scripts:

    // Bootstrap 3
    { test:/bootstrap-sass[\/\\]assets[\/\\]javascripts[\/\\]/, loader: 'imports-loader?jQuery=jquery' },

    // Bootstrap 4
    { test: /bootstrap[\/\\]dist[\/\\]js[\/\\]umd[\/\\]/, loader: 'imports-loader?jQuery=jquery' },
  ],
},

Note: if you're not concerned about Windows, the lines look like this (simpler regexp pattern):

// Bootstrap 3
{ test: /bootstrap-sass\/assets\/javascripts\//, loader: 'imports-loader?jQuery=jquery' },

// Bootstrap 4
{ test: /bootstrap\/dist\/js\/umd\//, loader: 'imports-loader?jQuery=jquery' },

Icon fonts

Bootstrap uses icon fonts. If you want to load them, don't forget to setup url-loader or file-loader in webpack config:

module: {
  loaders: [
    { test: /\.(woff2?|svg)$/, loader: 'url-loader?limit=10000' },
    { test: /\.(ttf|eot)$/, loader: 'file-loader' },
  ],
},

FAQ

Using Bootstrap mixins and variables

You should use sass-resources-loader in your webpack config.

In your webpack.config.js:

module.exports = {

  // stuff removed for clarity ...

  module: {
    loaders: [
      // stuff removed for clarity ...
      {
        test: /\.scss$/,
        loader: ExtractTextPlugin.extract(
          'style-loader',
          'css-loader?modules&importLoaders=2&localIdentName=[name]__[local]__[hash:base64:5]' +
          '!sass-loader' +
          '!sass-resources-loader'
        ),
      },
      // stuff removed for clarity ...
    ],
  },

  // stuff removed for clarity ...

  sassResources: './config/sass-resources.scss',
}

And in your ./config/sass-resources.scss:

// Make variables and mixins available when using CSS modules.
@import "node_modules/bootstrap-sass/assets/stylesheets/bootstrap/_variables";
@import "node_modules/bootstrap-sass/assets/stylesheets/bootstrap/_mixins";

You can then use mixins and variables from Bootstrap in your own code.

Using a custom location for bootstrap module

By default, bootstrap-loader will try to resolve bootstrap from where bootstrap-loader has been installed. In certain situations (e.g. npm linking, using a custom package installer) it may not be resolvable. In this case, you can pass in the location manually.

require('bootstrap-loader?bootstrapPath=/path/to/bootstrap');

// or

entry: [ 'bootstrap-loader?bootstrapPath=/path/to/bootstrap', './app' ]

Contributing

See Contributing to get started.

License

MIT.

Examples and related libraries

Useful Q&A

We'll identify issues that are questions.


Thank you from Justin Gordon and ShakaCode

The ShakaCode team has availability to help your project. If your team might need my help, please email me for a free half-hour project consultation, on anything from React on Rails to any aspect of web or mobile application development for both consumer and enterprise products.

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.
  • Augmenting your team to get your product completed more efficiently and quickly.

I appreciate your attention and sharing of these offerings with anybody that we can help. Your support allows me to bring you and your team front-end happiness in the Rails world.

Aloha and best wishes from the ShakaCode team!

Supporters

JetBrains ScoutAPM Control Plane
BrowserStack Rails Autoscale Honeybadger Reviewable

The following companies support our open source projects, and ShakaCode uses their products!

bootstrap-loader's People

Contributors

ahangarha avatar alecf avatar alex35mil avatar alexkval avatar allenfang avatar bertho-zero avatar dependabot[bot] avatar dzirtusss avatar ghoshnirmalya avatar hedefalk avatar horizonxp avatar judahmeek avatar justin808 avatar kevinzwhuang avatar larsw avatar mdgraser avatar mgedmin avatar mircowidmer avatar navarroaxel avatar phyks avatar rmobis avatar roblarsen avatar robwise avatar ruiaraujo avatar ryantd avatar samueldemoura avatar stephanwilliams avatar velveret avatar x-yuri avatar zebrastealer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bootstrap-loader's Issues

ERROR in ./~/bootstrap-loader/lib/bootstrap.scripts.loader.js!./~/bootstrap-loader/no-op.js

Hi,

When I run webpack-dev-server, I get this error 12-13 times with minor line/position variations:

ERROR in ./~/bootstrap-loader/lib/bootstrap.scripts.loader.js!./~/bootstrap-loader/no-op.js
Module not found: Error: Cannot resolve module 'imports' in /home/larsw/shave/node_modules/bootstrap-loader
 @ ./~/bootstrap-loader/lib/bootstrap.scripts.loader.js!./~/bootstrap-loader/no-op.js 1:0-69

my ./app/app.js file is currently empty.

My webconfig.config.js:

/*global __dirname */
var webpack = require('webpack');
var path = require('path');

module.exports = {
    entry: [
        'webpack-dev-server/client?http://localhost:8080', // WebpackDevServer host and port
        'webpack/hot/only-dev-server', // "only" prevents reload on syntax errors
        'bootstrap-loader',
        path.resolve(__dirname, "app", "app.js")],
    output: {
        filename: "bundle.js",
        path: __dirname
    },
    plugins: [
        new webpack.ProvidePlugin({
        $: "jquery",
        jQuery: "jquery"
        })
    ],
    resolve: {
      extensions: ['','.js','.jsx']
    },
    module: {
    loaders: [
        {
        test: /\.jsx?$/,
        exclude: /node_modules/,
        loaders: ["react-hot", "babel?cacheDirectory"],
        },
        { test: /\.(woff2?|svg)$/, loader: 'url?limit=10000' },
        { test: /\.(ttf|eot)$/, loader: 'file' },
        { test: /bootstrap-sass\/assets\/javascripts\//, loader: 'imports?jQuery=jquery' },
        { test: /\.scss$/, loaders: ["style", "css", "sass"] }
    ],
    },
}

and my package.json:

{
  "name": "foobar",
  "version": "1.0.0",
  "description": "foobar",
  "main": "index.js",
  "scripts": {
    "dev": "webpack-dev-server --port 8080 --hot --inline"
  },
  "author": "Lars Wilhelmsen",
  "license": "Apache-2.0",
  "dependencies": {
    "react": "^0.14.6"    
  },
  "devDependencies": {
    "babel": "^6.3.26",
    "babel-loader": "^6.2.1",
    "babel-plugin-transform-decorators-legacy": "^1.3.4",
    "babel-preset-es2015": "^6.3.13",
    "babel-preset-react": "^6.3.13",
    "bootstrap-loader": "^1.0.6",
    "bootstrap-sass": "^3.3.6",
    "css-loader": "^0.23.1",
    "file-loader": "^0.8.5",
    "font-loader": "^0.1.2",
    "node-sass": "^3.4.2",
    "react-hot-loader": "^1.3.0",
    "resolve-url-loader": "^1.4.3",
    "sass-loader": "^3.1.2",
    "style-loader": "^0.13.0",
    "svg-loader": "0.0.2",
    "url-loader": "^0.5.7",
    "webpack": "^1.12.12",
    "webpack-dev-server": "^1.14.1"
  }
}

Module build failed

I followed the instructions but I keep getting errors:

ERROR in ./~/css-loader!./~/sass-loader!./~/bootstrap-loader/lib/bootstrap.styles.loader.js!./~/bootstrap-loader/no-op.js
Module build failed:
module.exports = {};

^
      File to import not found or unreadable: ..โ™‚ootstrap-sass
ssetsstylesheetsโ™‚ootstrap_variables
Parent style sheet: stdin
      in C:\Users\Administrator\Dropbox\projects\spDash\node_modules\bootstrap-loader\no-op.js (line 1, column 1)
 @ ./~/style-loader!./~/css-loader!./~/sass-loader!./~/bootstrap-loader/lib/bootstrap.styles.loader.js!./~/bootstrap-loader/no-op.js 4:14-121

My entry file looks like this:

require('expose?$!expose?jQuery!jquery');
require('angular');
require('angular-animate');
require('angular-sanitize');
require('angular-resource');
require('angular-ui-bootstrap');
require('angular-ui-router');
require('angular-ui-select/select');
require('datatables');
require('datatables-tabletools');
require('expose?moment!moment')
require('jquery-ui');
require('lodash');
require('expose?Promise!bluebird');
require('expose?toastr!toastr');
require('../../lib/jquery.SPServices-2014.02');
require('bootstrap-loader');

Webpack config:

var webpack = require('webpack')
module.exports = {
  entry: {
    'spdash': './app/js/loader.js'
  },
  output: {
    filename: 'bundle.js',
  },
  // devtool: 'source-map',
  plugins: [
    new webpack.optimize.UglifyJsPlugin({
      minimize: true,
      compress: {
        warnings: false
      }
    }),
    new webpack.IgnorePlugin(/^\.\/locale$/, [/moment$/])
  ]
};

And I have all the loaders setup

Combining Bootstrap with a custom theme pack (Bootswatch).

Hi,

Just a question from a newbie; if I'd like to use one of the Bootswatch themes (https://bootswatch.com) that are provided as _bootswatch.scss and _variables.scss for each theme, should I use the appStyles and bootstrapCustomizations to point to them, like:

bootstrapCustomizations: ./styles/_variables.scss
appStyles: ./styles/_bootswatch.scss

I've tried to use one of the themes, and I notice that it doesn't pick up the styles correctly.

Error after adding

After adding the bootstrap loader I get this error

ERROR in 
      For Node <= v0.12.x Babel polyfill is required.
      Make sure it's installed in your 'node_modules/' directory.

 @ ./~/bootstrap-loader/loader.js 1:0-44

I have node v 0.12.7
babel-polyfill exists in my node_modules

Option for javascript config file (in addition to yaml and json)?

First thanks for this it's really helpful!

I needed to override a bootstrap mixin, so I set the mixins option to false and then in a pre customisations file I am doing

// load the mixins
@import "bootstrap/mixins";

// override some mixins
...
}

I also then set the styleLoaders property to this

styleLoaders:
  - style
  - css
  - sass?includePaths[]=node_modules/bootstrap-sass/assets/stylesheets

My question is, is there a nicer way of determine the include path than hard coding it?

If the config file was javascript I think I might be able to use https://www.npmjs.com/package/resolve to generate the path. Would it be possible to make a javascript file which exports config an option?

Thanks!

Error: Cannot find module './lib/bootstrap.loader?extractStyles!./no-op.js'

I am unable to get past the error Error: Cannot find module './lib/bootstrap.loader?extractStyles!./no-op.js' with my isomorphic/universal app. I am using webpack to compile both the server and client (same loaders used).

Please advise.

Below are my relevant configs:

.bootstraprc

---
# Output debugging info
loglevel: debug

# Major version of Bootstrap: 3 or 4
bootstrapVersion: 3

# If Bootstrap version 4 is used - turn on/off flexbox model
useFlexbox: true

# Webpack loaders, order matterse
styleLoaders:
  - style
  - css
  - postcss
  - sass

scripts: false

Client webpack config:

{ entry:
   { main:
      [ 'babel-polyfill',
        'bootstrap-loader/extractStyles',
        './src/client.js' ] },
  output:
   { path: '/Users/chris/github/app-frontend/build/public',
     filename: '[name]-[hash].js',
     chunkFilename: '[name]-[chunkhash].js',
     publicPath: '/dist/' },
  target: 'web',
  plugins:
   [ ExtractTextPlugin {
       filename: '[name]-[chunkhash].css',
       options: { allChunks: true },
       id: 1 },
     DedupePlugin {},
     UglifyJsPlugin { options: { compress: { screw_ie8: false, warnings: true } } },
     AggressiveMergingPlugin { options: {} },
     Webpack_isomorphic_tools_plugin {
       options:
        { webpack_assets_file_path: 'build/webpack-assets.json',
          webpack_stats_file_path: 'build/webpack-stats.json',
          assets: {} },
       log:
        Log {
          options: { debug: undefined },
          preamble: '[webpack-isomorphic-tools/plugin]' },
       regular_expressions: {},
       regularExpressions: {} },
     IgnorePlugin { resourceRegExp: /node-fetch/, contextRegExp: undefined },
     ProvidePlugin {
       definitions:
        { 'typeof window': '"object"',
          fetch: 'exports?self.fetch!whatwg-fetch' } },
     DefinePlugin {
       definitions:
        { __CLIENT__: true,
          __SERVER__: false,
          __DEVTOOLS__: false,
          __DEVELOPMENT__: false,
          'process.env.NODE_ENV': '"production"' } },
     OccurrenceOrderPlugin { preferEntry: undefined } ],
  devtool: 'source-map',
  context: '/Users/chris/github/app-frontend',
  progress: true,
  resolve:
   { root: '/Users/chris/github/app-frontend/src',
     modulesDirectories: [ 'node_modules' ],
     extensions: [ '', '.json', '.js', '.jsx' ] },
  module:
   { loaders:
      [ { test: /\.jsx?$/,
          exclude: /node_modules/,
          loaders: [ 'babel?{"presets":["es2015","react","stage-2"],"plugins":["transform-jscript","transform-es3-member-expression-literals","transform-es3-property-literals"],"env":{"production":{"plugins":["react-remove-prop-types","transform-react-constant-elements","transform-react-inline-elements"]},"test":{"plugins":["rewire"]}}}' ] },
        { test: /\.json$/, loader: 'json-loader' },
        { test: /\.scss$/,
          loader: '/Users/chris/github/app-frontend/node_modules/extract-text-webpack-plugin/loader.js?{"omit":1,"extract":true,"remove":true}!style!css?sourceMap&modules&importLoaders=2&localIdentName=[local]___[hash:base64:5]!postcss!sass?sourceMap&outputStyle=expanded&sourceMap=true&sourceMapContents=true' },
        { test: /\.png$/, loader: 'url-loader?limit=1' } ] },
  postcss: [Function: postcss] }

Server webpack config:

{ entry:
   { main:
      [ 'babel-polyfill',
        'bootstrap-loader/extractStyles',
        './src/server.js' ] },
  output:
   { path: '/Users/chris/github/app-frontend/build',
     filename: 'server.js',
     chunkFilename: 'server-[chunkhash].js',
     libraryTarget: 'commonjs2',
     publicPath: '/dist/' },
  devtool: 'source-map',
  target: 'node',
  node:
   { console: false,
     global: false,
     process: false,
     Buffer: false,
     __filename: false,
     __dirname: false },
  externals: [ [Function] ],
  plugins:
   [ BannerPlugin {
       options: { raw: true, entryOnly: false },
       banner: 'require(\'source-map-support\').install();' },
     ExtractTextPlugin {
       filename: 'server-[name].css.ignore',
       options: { allChunks: true },
       id: 2 },
     DefinePlugin {
       definitions:
        { __CLIENT__: false,
          __SERVER__: true,
          __DEVTOOLS__: false,
          __DEVELOPMENT__: false,
          'process.env.NODE_ENV': '"production"' } },
     OccurrenceOrderPlugin { preferEntry: undefined } ],
  context: '/Users/chris/github/app-frontend',
  progress: true,
  resolve:
   { root: '/Users/chris/github/app-frontend/src',
     modulesDirectories: [ 'node_modules' ],
     extensions: [ '', '.json', '.js', '.jsx' ] },
  module:
   { loaders:
      [ { test: /\.jsx?$/,
          exclude: /node_modules/,
          loaders: [ 'babel?{"presets":["es2015","react","stage-2"],"plugins":["transform-jscript","transform-es3-member-expression-literals","transform-es3-property-literals"],"env":{"production":{"plugins":["react-remove-prop-types","transform-react-constant-elements","transform-react-inline-elements"]},"test":{"plugins":["rewire"]}}}' ] },
        { test: /\.json$/, loader: 'json-loader' },
        { test: /\.scss$/,
          loader: '/Users/chris/github/app-frontend/node_modules/extract-text-webpack-plugin/loader.js?{"omit":1,"extract":true,"remove":true}!style!css?sourceMap&modules&importLoaders=2&localIdentName=[local]___[hash:base64:5]!postcss!sass?sourceMap&outputStyle=expanded&sourceMap=true&sourceMapContents=true' },
        { test: /\.png$/, loader: 'url-loader?limit=1' } ] },
  postcss: [Function: postcss] }
node version: node/4.4.0
chris ๎‚ฐ ~/github/app-frontend ๎‚ฐ ๎‚  feature/desktop โ— ๎‚ฐ npm show bootstrap-loader

{ name: 'bootstrap-loader',
  description: 'Boostrap for Webpack',
  'dist-tags': { latest: '1.0.10', 'ver0.1.0-beta1': '0.1.0-beta1' },
  versions:
   [ '0.0.1',
     '0.0.2',
     '0.0.3',
     '0.0.4',
     '0.0.5',
     '0.1.0-beta1',
     '1.0.0-rc',
     '1.0.0',
     '1.0.1',
     '1.0.2',
     '1.0.3',
     '1.0.4',
     '1.0.5',
     '1.0.6',
     '1.0.7',
     '1.0.8',
     '1.0.9',
     '1.0.10' ],
  maintainers:
   [ 'alex.fedoseev <[email protected]>',
     'justin808 <[email protected]>',
     'shakacode <[email protected]>' ],
  time:
   { modified: '2016-03-18T09:21:45.275Z',
     created: '2015-11-11T04:18:27.648Z',
     '0.0.1': '2015-11-11T04:18:27.648Z',
     '0.0.2': '2015-11-13T21:42:01.200Z',
     '0.0.3': '2015-11-14T16:34:29.354Z',
     '0.0.4': '2015-11-15T11:51:10.296Z',
     '0.0.5': '2015-11-16T16:34:46.825Z',
     '0.1.0-beta1': '2015-12-07T21:26:12.541Z',
     '1.0.0-rc': '2015-12-11T16:53:04.622Z',
     '1.0.0': '2015-12-23T23:11:25.616Z',
     '1.0.1': '2015-12-23T23:30:08.675Z',
     '1.0.2': '2016-01-04T09:58:33.675Z',
     '1.0.3': '2016-01-06T10:55:18.561Z',
     '1.0.4': '2016-01-16T20:43:36.218Z',
     '1.0.5': '2016-01-16T20:48:54.996Z',
     '1.0.6': '2016-01-24T17:55:14.819Z',
     '1.0.7': '2016-01-26T08:00:22.822Z',
     '1.0.8': '2016-02-08T10:22:57.867Z',
     '1.0.9': '2016-02-29T10:33:27.993Z',
     '1.0.10': '2016-03-18T09:21:45.275Z' },
  homepage: 'https://github.com/shakacode/bootstrap-loader#readme',
  keywords: [ 'bootstrap', 'twitter' ],
  repository:
   { type: 'git',
     url: 'git+https://github.com/shakacode/bootstrap-loader.git' },
  bugs: { url: 'https://github.com/shakacode/bootstrap-loader/issues' },
  license: 'MIT',
  readmeFilename: 'README.md',
  users: { yatsu: true },
  version: '1.0.10',
  main: 'loader.js',
  scripts:
   { start: 'npm run lint && npm run clean && npm run dev',
     dev: 'babel --watch --out-dir lib src',
     build: 'babel --out-dir lib src',
     lint: 'eslint --ext .js .',
     clean: 'rm -rf lib',
     prerelease: 'npm run lint && npm run clean && npm run build',
     preversion: 'npm run prerelease',
     prepublish: 'npm run prerelease',
     'release:patch': 'scripts/release patch',
     'release:minor': 'scripts/release minor',
     'release:major': 'scripts/release major' },
  authors:
   [ 'Justin Gordon <[email protected]> (https://github.com/justin808)',
     'Alex Fedoseev <[email protected]> (https://github.com/alexfedoseev)' ],
  peerDependencies:
   { 'css-loader': '*',
     'node-sass': '*',
     'resolve-url-loader': '*',
     'sass-loader': '*',
     'url-loader': '*',
     webpack: '*' },
  dependencies:
   { chalk: '^1.1.1',
     'escape-regexp': '0.0.1',
     'js-yaml': '^3.4.3',
     'loader-utils': '^0.2.11',
     resolve: '^1.1.6',
     semver: '^5.0.3',
     'strip-json-comments': '^1.0.4' },
  devDependencies:
   { babel: '^6.0.15',
     'babel-cli': '^6.1.4',
     'babel-preset-es2015': '^6.1.4',
     eslint: '^1.10.3',
     'eslint-config-airbnb': '^2.0.0' },
  gitHead: '2fadab2ddae2e33abee648a598bcc4c92e91f9e3',
  dist:
   { shasum: '67f112c240eb5d8a7b9d017791798d497d1f2206',
     tarball: 'http://registry.npmjs.org/bootstrap-loader/-/bootstrap-loader-1.0.10.tgz' },
  directories: {} }

Debug output:

[bootstrap-loader]:  Hey, we're in DEBUG mode! Yabba dabba doo!

[bootstrap-loader]:  Context: /Users/chris/github/app-frontend/node_modules/bootstrap-loader

[bootstrap-loader]:  Using Bootstrap version: 3

[bootstrap-loader]:  Using Bootstrap module: bootstrap-sass

[bootstrap-loader]:  Bootstrap module location (abs): /Users/chris/github/app-frontend/node_modules/bootstrap-sass

[bootstrap-loader]:  Bootstrap module location (rel): ../bootstrap-sass

[bootstrap-loader]:  Bootstrap NPM package version: 3.3.6

[bootstrap-loader]:  Query from webpack config: ?extractStyles

[bootstrap-loader]:  Normalized params:
 { bootstrapPath: '/Users/chris/github/app-frontend/node_modules/bootstrap-sass',
  bootstrapRelPath: '../bootstrap-sass',
  bootstrapVersion: 3,
  loglevel: 'debug',
  preBootstrapCustomizations: undefined,
  bootstrapCustomizations: undefined,
  appStyles: undefined,
  useFlexbox: true,
  useCustomIconFontPath: undefined,
  extractStyles: true,
  styleLoaders: [ 'style', 'css', 'postcss', 'sass' ],
  styles: false,
  scripts: false }

[bootstrap-loader]:  Requiring:

Full error:

Error: Cannot find module './lib/bootstrap.loader?extractStyles!./no-op.js'
    at Function.Module._resolveFilename (module.js:325:15)
    at Function.Module._load (module.js:276:25)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/Users/chris/github/app-frontend/node_modules/bootstrap-loader/extractStyles.js:1:1)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)

Surprising configuration behavior

The default values of the configuration are only applied if no configuration is present at all. That is uncommon and confusing.

The README hints at it by saying something like: if a .bootstraprc isn't present at all, the default one for Bootstrap 3 is used. It would be less surprising, if the individual configuration attributes were falling back to the (documented) default values. Else, a special note about this behavior in the README might be appropriate.

Navbar styles don't seem to be working with Bootstrap 4

I have installed the package using the guide on the readme, everything seems to be working fine.

But it seems that the navbar styles don't seem to be working, e.g. this is my navbar:

http://v4-alpha.getbootstrap.com/components/navbar/#color-schemes

   <nav class="navbar navbar-dark bg-inverse">
        <a href="#" class="navbar-brand">PugIt</a>
        <ul class="nav navbar-nav">
            <li class="nav-item active">
                <a href="/home" class="nav-link"><i class="fa fa-home"> </i> Home</a>
            </li>
            <li class="nav-item">
                <a href="/about" class="nav-link"><i class="fa fa-ellipsis-v"> </i> About Us</a>
            </li>
            <li class="nav-item">
                <a href="/faq" class="nav-link"><i class="fa fa-question"> </i> FAQ</a>
            </li>
        </ul>
        <ul class="nav navbar-nav pull-right">
            <li class="nav-item">
                <a href="/auth/steam" class="navButtonLogin nav-link"></a>
            </li>
        </ul>
    </nav>

But my navbar has no background at all, but it doesn't structure properly so am I missing something? I'm using the config file from the default .bootstrap4rc or whatever thanks.

WINDOWS: Uncaught ReferenceError: jQuery is not defined

I have an error: Uncaught ReferenceError: jQuery is not defined
I have imports-loader installed but I still have this error.

Could you please help me to resolve it?
this is my webpack.config.js

var path = require('path');
var webpack = require('webpack');

module.exports = {
    devtool: 'source-map',
    entry: [
        'webpack-hot-middleware/client',
        'bootstrap-loader',
        './app/index'
    ],
    output: {
        path: path.join(__dirname, 'dist'),
        filename: 'bundle.js',
        publicPath: '/static/'
    },
    plugins: [
        new webpack.optimize.OccurenceOrderPlugin(),
        new webpack.HotModuleReplacementPlugin(),
        new webpack.NoErrorsPlugin()
    ],
    module: {
        loaders: [
            // es6, JSX
            {
                test: /\.js$/,
                loader: 'babel',
                exclude: /node_modules/,
                include: __dirname,
                query: {
                    cacheDirectory: true,
                    presets: ['es2015', 'react', 'stage-0']
                }
            },
            // SASS as CSS modules
            {
                test: /\.scss$/,
                loaders: [
                    "style",
                    "css?modules&importLoaders=1&localIdentName=[path]___[name]__[local]___[hash:base64:5]",
                    "sass"
                ]
            },
            // fonts
            {
                test: /\.(woff2?|ttf|eot|svg)$/,
                loader: 'url?limit=10000'
            },

            // Bootstrap 3
            {test: /bootstrap-sass\/assets\/javascripts\//, loader: 'imports?jQuery=jquery'}
        ]
    }
}

looks like yours in your examples...

bootstrapCustomizations Isn't Loading?

It doesn't appear that the bootstrapCustomizations file is being loaded and overriding the Bootstrap variables. Below is my .bootstraprc file.

Any assistance/direction would be greatly appreciated. Thank you!

# Output debugging info
# loglevel: debug

# Major version of Bootstrap: 3 or 4
bootstrapVersion: 4

# If Bootstrap version 4 is used - turn on/off flexbox model
useFlexbox: false

# Webpack loaders, order matters
styleLoaders:
  - style
  - css
  - sass

# Extract styles to stand-alone css file
# Different settings for different environments can be used,
# It depends on value of NODE_ENV environment variable
# This param can also be set in webpack config:
#   entry: 'bootstrap-loader/extractStyles'
extractStyles: true
# env:
#   development:
#     extractStyles: false
#   production:
#     extractStyles: true


# 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


# This gets loaded after bootstrap/variables is loaded
# Thus, you may customize Bootstrap variables
# based on the values established in the Bootstrap _variables.scss file
#
bootstrapCustomizations: ./scss/_variables.scss

# Import your custom styles here
# Usually this endpoint-file contains list of @imports of your application styles
#
# appStyles: ./path/to/your/app/styles/endpoint.scss


### Bootstrap styles
styles:

  # Mixins
  mixins: true

  # Reset and dependencies
  normalize: true
  print: true

  # Core CSS
  reboot: true
  type: true
  images: true
  code: true
  grid: true
  tables: true
  forms: true
  buttons: true

  # Components
  animation: false
  dropdown: false
  button-group: false
  input-group: false
  custom-forms: false
  nav: true
  navbar: true
  card: false
  breadcrumb: false
  pagination: false
  pager: false
  labels: false
  jumbotron: false
  alert: false
  progress: false
  media: false
  list-group: false
  responsive-embed: false
  close: false

  # Components w/ JavaScript
  modal: false
  tooltip: false
  popover: false
  carousel: false

  # Utility classes
  utilities: true
  utilities-background: true
  utilities-spacing: true
  utilities-responsive: true

### Bootstrap scripts
scripts:
  alert: false
  button: false
  carousel: false
  collapse: false
  dropdown: false
  modal: false
  popover: false
  scrollspy: false
  tab: false
  tooltip: false
  util: true

How to add overriding rules

I recognize that there is a pre-customization and a customization file, but both seem to be included prior to all rules being defined. What is best practice for overriding rules, that cannot be adjusted using variables?

For example, I want to achieve another disabled style for my buttons, and tried adding this to my customizations.scss file:

.btn {
  &.disabled,
  &[disabled],
  fieldset[disabled] & {
    @include opacity(.2);
  }
}

But this rule is overridden by the default Bootstrap rule, which tells me that my custom rule is included prior to the default.

How would I go about this?

`npm i` hangs in examples/css-modules

Hey,
I am extremly excited about this project, great work so far!

There is just a tiny problem that keeps me from checking out the example. Was just wanting to have a quick look at the css-modules example and when I run npm i it hangs at:
loadDep:bootstrap โ†’ after โ–Œ โ•ขโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ•Ÿ

What am I doing wrong?

I am using npm version 3.5.2

Best Regards

Impossible to disable sass sourceMaps

Source maps are slow. It should not add them unless specified in the .bootstraprc.

  // We need to check if user's loader already contains sourceMap param
  // And if it's not there - inject it
  var sassLoaderWithSourceMap = undefined;
  if (sassLoaderQuery) {
    sassLoaderWithSourceMap = sassLoaderQuery.includes('sourceMap') ? sassLoader : sassLoader + '&sourceMap';
  } else {
    sassLoaderWithSourceMap = sassLoader + '?sourceMap';
  }

Unable to load WOFF, WOFF2, TTF files from browser

I've got bootstrap-loader mostly working with bootstrap-react. I'm using Bootstrap 3 with default dootstrap-loader config in my .bootstraprc.

I'm using webpack to build the app, and webpack is spitting the bundled JS, CSS and artifacts into the ./build/directory. My JS loads fine and bootstrap-loader is applying Bootstrap to the page.

My problem is that when I try to add a glyphicon I get 404 errors in the browser console about woff, woff2 and ttf files. Well, that's because the bootstrap css is trying to get the files at localhost/file-name-here.woff and so on. Those files are being put under the ./build/ directory so the compiled CSS should be looking at localhost/build/file-name-here.woff.

Any ideas how I can address this?

Module build failed: TypeError: Object style,css,sass has no method 'find'

when I use bootstrap-loader to package my product production, I got the following error

ERROR in ./~/bootstrap-loader/lib/bootstrap.loader.js?extractStyles!./~/bootstrap-loader/no-op.js
Module build failed: TypeError: Object style,css,sass has no method 'find'
    at exports.default (/home/user1/varOne3/varOne/varOne-web/src/main/webapp/node_modules/bootstrap-loader/lib/utils/processStyleLoaders.js:20:28)
    at Object.module.exports.pitch (/home/user1/varOne3/varOne/varOne-web/src/main/webapp/node_modules/bootstrap-loader/lib/bootstrap.loader.js:107:91)
 @ ./~/bootstrap-loader/extractStyles.js 1:0-58

I used [email protected] or [email protected], this issue still remain
But if I upgrade nodejs to 4.0.0, this issues disappear

Specify config file location

Is it possible to specify the config file location? I don't wan't my bootstrap config on my project root. I am using some build scripts with gulp and have all my theme related files in a specific subfolder. It would be good if I can specify the config file location like I was able to with bootstrap-sass-loader.

Errors when use bootstrap-loader as stand-alone entry point.

repo: bootstrap-loader-entry-point

ERROR in ./~/bootstrap-loader/lib/bootstrap.scripts.loader.js!./~/bootstrap-loader/no-op.js
Module not found: Error: Cannot resolve module 'imports' in /Users/dima/sunflowers/static/node_modules/bootstrap-loader
 @ ./~/bootstrap-loader/lib/bootstrap.scripts.loader.js!./~/bootstrap-loader/no-op.js 1:0-42

ERROR in ./~/bootstrap-loader/lib/bootstrap.scripts.loader.js!./~/bootstrap-loader/no-op.js
Module not found: Error: Cannot resolve module 'imports' in /Users/dima/sunflowers/static/node_modules/bootstrap-loader
 @ ./~/bootstrap-loader/lib/bootstrap.scripts.loader.js!./~/bootstrap-loader/no-op.js 2:0-43

ERROR in ./~/bootstrap-loader/lib/bootstrap.scripts.loader.js!./~/bootstrap-loader/no-op.js
Module not found: Error: Cannot resolve module 'imports' in /Users/dima/sunflowers/static/node_modules/bootstrap-loader
 @ ./~/bootstrap-loader/lib/bootstrap.scripts.loader.js!./~/bootstrap-loader/no-op.js 3:0-40

ERROR in ./~/bootstrap-loader/lib/bootstrap.scripts.loader.js!./~/bootstrap-loader/no-op.js
Module not found: Error: Cannot resolve module 'imports' in /Users/dima/sunflowers/static/node_modules/bootstrap-loader
 @ ./~/bootstrap-loader/lib/bootstrap.scripts.loader.js!./~/bootstrap-loader/no-op.js 4:0-44

ERROR in ./~/bootstrap-loader/lib/bootstrap.scripts.loader.js!./~/bootstrap-loader/no-op.js
Module not found: Error: Cannot resolve module 'imports' in /Users/dima/sunflowers/static/node_modules/bootstrap-loader
 @ ./~/bootstrap-loader/lib/bootstrap.scripts.loader.js!./~/bootstrap-loader/no-op.js 5:0-41

Missing dependency

Hey. Really nice work on packaging bootstrap for webpack.
README doesn't mention that file-loader package is needed, otherwise it won't work.

Other than that, I am having some weird problem?

ERROR in Loader [...]/node_modules/url/url.js?limit=10000 didn't return a function
 @ ./~/css-loader!./~/resolve-url-loader!./~/sass-loader?sourceMap!./~/bootstrap-loader/lib/bootstrap.styles.loader.js!./~/bootstrap-loader/no-op.js 6:4358-4444

ERROR in Loader [...]/node_modules/url/url.js?limit=10000 didn't return a function
 @ ./~/css-loader!./~/resolve-url-loader!./~/sass-loader?sourceMap!./~/bootstrap-loader/lib/bootstrap.styles.loader.js!./~/bootstrap-loader/no-op.js 6:4477-4562

ERROR in Loader [...]/node_modules/url/url.js?limit=10000 didn't return a function
 @ ./~/css-loader!./~/resolve-url-loader!./~/sass-loader?sourceMap!./~/bootstrap-loader/lib/bootstrap.styles.loader.js!./~/bootstrap-loader/no-op.js 6:4714-4798

ERROR in only one instance of babel-polyfill is allowed @ ./~/bootstrap-loader/loader.js 1:0-44

I upgrade bootstrap-loader according #13, and it work for [email protected] and earlier, but I got another problem for babel-polyfill is loaded repeatedly.

the error message is in the following:

ERROR in only one instance of babel-polyfill is allowed  @ ./~/bootstrap-loader/loader.js 1:0-44

The root cause is I wrote my dev webpack config with es6, and I add require('babel/register'); this line in my webpack-dev-server.js

Anyway, if re-write whole webpack config with es5 and it's work, so have any idea to solve it or did I miss something?

Thanks :)

Missing styles with bootstrap 4

I have been trying to get bootstrap 4 running in little test app I am putting together but am having issues. The container is hidden behind the nav.

JakeGinnivan/WikiThing@9ec255b

As far as I can tell there are clearfix styles missing from the mixins, there may be other things missing as well. I cannot see what would be causing it and will probably just drop bootstrap 4 but thought id report my issue to see if someone knows why I am seeing what I am seeing.

Allow picking bootstrap 3/4 (locked) with default configuration file.

Below is possible feature enhancement.

HOWEVER, after some more discussions on this, we really want to encourage projects to use their own copy of the .bootstraprc file, as that allows specifying a post-loading bootstrap customization file. Here's an example.


The problem is that default configuration file is at a specific bootstrap version.

So if you don't specify a configuration file, you get bootstrap 3 now, but someday in the future, you might unexpectedly upgrade to bootstrap 4.

We will probably bump the major version of the bootstrap-loader when we go to Bootstrap v4.

Maybe we should offer a syntax like:

require('bootrap-loader?version=3) to use the bootstrap version 3 config.

Alternately, if no config file is specified, could we just check which peer dependency is available and go with that?

(side note: We allow the require of this: bootstrap-loader/extractStyles to specify the default for extractStyles to be on for production)

CC: @alexfedoseev

How to use sass glob loader along with bootstrap-loader

First of all my project is webpack-bootstrap-reactBootstrap. Also, I am having lot of custom scss files.
Before bootstrap-loader in my project, my own scss works(inside src folder) fine as loader used are style, css, postcss and sass. With this, I am having all the bootstrap scss and js files in my src folder, so they also works fine with my own scss.

(Now, I removed these bootstrap scss and js files)
And after installing bootstrap-loader and dependencies as in Doc, the bootstrap-sass(from node modules) works but not my own scss files.

So, Doc says, to use appStyles: ./path/to/your/app/styles/endpoint.scss which works fine if I put all my scss imports individually inside endpoints.scss which is not possible if I've 50 files.

Basically, I needed something, that could work as
@import styles/**/* inside endpoints.scss but it doesn't work.

So I want to use sass glob loader as on https://github.com/Aintaer/import-glob-loader.
which doesn't work with bootstrap-loader if I used the following:
@import styles/**/* inside endpoints.scss instead of individual imports but it doesn't work.

It says, it doesn't identify the file *

So, in in my .bootstraprc itself, I tried using,

"appStyles": "./src/styles/**/*",
"styleLoaders": ["style", "css", "sass", "import-glob"],

And VOILA!! It works... because of import-glob. This way isn't given in bootstrap-loader Doc!

But still I wanted to make it work in endpoints.scss because it is supposed to work
Need help.. ๐Ÿ˜‡

(Btw, for import-glob to make work, using "require(..)" or "preLoader" is not necessary as given in Doc in the link I gave.)

webpack works, not seeing styles

This is my webpack.config.js

module.exports = {
  context: __dirname + '/app',
  entry: [
    'bootstrap-loader',
    './app.js',
    './index.html',
  ],

  output: {
    filename: 'app.js',
    path: __dirname + '/dist',
  },
  module: {
    loaders: [
      {
        test: /\.jsx?$/,
        exclude: /(node_modules)/,
        loader: 'babel',
        query: {
          presets: ['react', 'es2015']
        }
      },
      { test: /\.html$/, loader: 'file?name=[name].[ext]' },
      { test: /\.css$/, loaders: [ 'style', 'css', 'postcss' ] },
      { test: /\.scss$/, loaders: ['style','css','sass'] },
      // Bootstrap 4
      { test: /bootstrap\/dist\/js\/umd\//, loader: 'imports?jQuery=jquery' },
    ],
  },
}

I can get a successful webpack command, but I'm not seeing any styles in my app. Am I missing something really obvious?

Cannot find modules

Hey guys,

I've made a small boilerplate that i'll be using for my future projects and hoped to use this loader but i can't quite configure it correctly.

Would it be possible to help point in the right direction? I'm sure it must be something simple however, I can't see what i've done differently.

You can view the config at the repo here : https://github.com/Webdesignwill/epicify

It keeps failing to load the modules :

__webpack_require__(!(function webpackMissingModule() { var e = new Error("Cannot find module \"./umd/util.js\""); e.code = 'MODULE_NOT_FOUND'; throw e; }()))
__webpack_require__(!(function webpackMissingModule() { var e = new Error("Cannot find module \"./umd/alert.js\""); e.code = 'MODULE_NOT_FOUND'; throw e; }()))
__webpack_require__(!(function webpackMissingModule() { var e = new Error("Cannot find module \"./umd/button.js\""); e.code = 'MODULE_NOT_FOUND'; throw e; }()))
__webpack_require__(!(function webpackMissingModule() { var e = new Error("Cannot find module \"./umd/carousel.js\""); e.code = 'MODULE_NOT_FOUND'; throw e; }()))
__webpack_require__(!(function webpackMissingModule() { var e = new Error("Cannot find module \"./umd/collapse.js\""); e.code = 'MODULE_NOT_FOUND'; throw e; }()))
__webpack_require__(!(function webpackMissingModule() { var e = new Error("Cannot find module \"./umd/dropdown.js\""); e.code = 'MODULE_NOT_FOUND'; throw e; }()))
__webpack_require__(!(function webpackMissingModule() { var e = new Error("Cannot find module \"./umd/modal.js\""); e.code = 'MODULE_NOT_FOUND'; throw e; }()))
__webpack_require__(!(function webpackMissingModule() { var e = new Error("Cannot find module \"./umd/scrollspy.js\""); e.code = 'MODULE_NOT_FOUND'; throw e; }()))
__webpack_require__(!(function webpackMissingModule() { var e = new Error("Cannot find module \"./umd/tab.js\""); e.code = 'MODULE_NOT_FOUND'; throw e; }()))
__webpack_require__(!(function webpackMissingModule() { var e = new Error("Cannot find module \"./umd/tooltip.js\""); e.code = 'MODULE_NOT_FOUND'; throw e; }()))
__webpack_require__(!(function webpackMissingModule() { var e = new Error("Cannot find module \"./umd/popover.js\""); e.code = 'MODULE_NOT_FOUND'; throw e; }()))

appStyles appear before bootstrap

Hi,

I've tried to add my custom .scss file and at .bootstraprc i setup like this:

bootstrapVersion: 3
styleLoaders:
 - style
 - css
 - sass

appStyles: ./src/sass/main.scss

styles:

# Mixins
mixins: true

# Reset and dependencies
normalize: true
print: true
glyphicons: true

# Core CSS
scaffolding: true
type: true
code: true
grid: true
tables: true
forms: true
buttons: true

# Components
component-animations: true
dropdowns: true
button-groups: true
input-groups: true
navs: true
navbar: true
breadcrumbs: true
pagination: true
pager: true
labels: true
badges: true
jumbotron: true
thumbnails: true
alerts: true
progress-bars: true
media: true
list-group: true
panels: true
wells: true
responsive-embed: true
close: true

# Components w/ JavaScript
modals: true
tooltip: true
popovers: true
carousel: true

# Utility classes
utilities: true
responsive-utilities: true

### Bootstrap scripts
 scripts:
  transition: true
  alert: true
  button: true
  carousel: true
  collapse: true
  dropdown: true
  modal: true
  tooltip: true
  popover: true
  scrollspy: true
  tab: true
  affix: true

The problem is when I build the file, my custom css is load before bootstrap file.

My main.scss:

@import '~animate.css/animate.min.css';

$color: blue;

body{
   color:$color;
}

As i recheck body{} is appear after bootstrap. but import file before bootstrap.

Is this suppose to be like this or I make a mistake?

Impossible to disable resolve-url-loader

If should be possible to disable it.

Also, its a bit confusing when the styleLoaders in the .bootstraprc is not the actual loaders used when requiring bootstrap.style.loader. A bit too magical IMHO.

processStyleLoaders.js#46

  if (!resolveUrlLoader) {
    loaders.splice(sassLoaderIndex, 0, 'resolve-url');
  }

My reasons for disabling relate to this bug Marak/colors.js#151

Error in running basic example

ERROR in .//bootstrap-loader/loader.js
Module not found: Error: Cannot resolve 'file' or 'directory' ./lib/bootstrap.loader in /Users/nick/Documents/Projects/bootstrap-loader/examples/basic/node_modules/bootstrap-loader
@ ./
/bootstrap-loader/loader.js 1:0-44

css-importer

Hey,

this is a feature request.
It would be really useful if it was possible to import css files as part of the app styles and get them compiled into the output file.

There is a package on npm that could do this: https://www.npmjs.com/package/node-sass-css-importer
Would you be interested to add a plugin option to the config file .bootstraprc where this could be specified?

The use case is fairly common I think. E.g. external library, widget stylesheets, or old css files. While the latter can be renamed the external ones can not with ease, especially if they are an npm module themselves.

Looking forward to hear you point of view on this!

Allow custom $icon-font-path

So I purchased an official theme from Bootstrap, which comes in LESS format. I converted it to Sass, and it uses a custom icon font, replacing glyphicons. It looks as though bootstrap-loader automatically adds the $icon-font-path to point to the location of Bootstrap's Sass files, if the Bootstrap version is 3.

It would be great to disable this default behaviour. Ideally, we should parse the incoming Sass files to see if $icon-font-path has already been declared, but I don't see anything in bootstrap-loader that currently does this.

Thus, perhaps it's best to add a configuration option. There are two possible ways we could do this:

  1. A boolean option that simply disables the default behaviour. It's then up to the user to properly declare $icon-font-path within their Sass files. I like this option because it allows the user to redeclare the variable within their Sass files if they need to.
  2. An option that explicitly points to the fonts folder. This is more explicit, but means the user is forced to point to a single location, and it's not indicated within their Sass files, which doesn't maintain separation of concerns.

Constantly bootstrap-loader folder in the node_module dir get renamed to .bootstrap-loader.DELETE

I'm using react starter kit as a boilerplate for building react application
For loading bootstrap i'm using BL (bootstrap-loader) and it was working fine.
After a while, when i installed react-bootstrap alongside BL, i saw an error
ERROR in multi main Module not found: Error: Cannot resolve module 'bootstrap-loader' in /Users/fakhruddinabdi/WebstormProjects/zeyton @ multi main
So i double check node_module for the folder and i saw it was renamed to .bootstrap-loader.DELETE

What's wrong with it ?

mixins not available when "mixins: true" specified

Hey -- awesome library. Thanks for it!

I'm trying to use mixins using your css-modules example, changing app/Layout/Layout.scss as follows:

.layout {
  display: block;
  position: relative;
  width: 100%;
  @include make-container();
}

In the .bootstraprc:

styles:
  mixins: true
  ...

However, when I try to run webpack (or the dev server), I get:

ERROR in ./~/css-loader?modules&importLoaders=2&localIdentName=[name]__[local]__[hash:base64:5]!./~/postcss-loader!./~/sass-loader!./app/layout/Layout.scss
Module build failed:
  @include make-container();
          ^
      No mixin named make-container

Backtrace:
    stdin:5
      in /Users/jeffrey/dev/learnersguild/bootstrap-loader/examples/css-modules/app/layout/Layout.scss (line 5, column 12)
 @ ./app/layout/Layout.scss 4:14-240 13:2-17:4 14:20-246

Any ideas?

Neither basic nor css-modules examples have a working build version

Hi! Thanks for great lib!

When trying to execute npm run build to compile a production version you get a public folder with js and css files, but html file is missing, so it's impossible to host a production version anywhere (e.g. put files to static web host).

The solution for this would probably be to include html-webpack-plugin.

Moreover, it would be cool to extract examples into a separate seed project, something like (webpack-bootstrap-seed)

Allow writing config to package.json

I personally do not like to pollute my project with numerous dot-files for configuration. Many libraries nowadays offer writing their configuration to the package.json file. This is particularly nice when all you need is only a few configurations like disabling scripts to disable jQuery. As an alternative (or addition), I'd find it nice to be able to add the path to an actual config file, so I may be able to put all my config files to a config folder instead of having a messy root folder.

Cannot find module './lib/bootstrap.loader!./no-op.js' when using on server

When using bootstrap loader on a server getting the following error:

Error: Cannot find module './lib/bootstrap.loader!./no-op.js'
    at Function.Module._resolveFilename (module.js:326:15)
    at Function.Module._load (module.js:277:25)
    at Module.require (module.js:354:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (d:\projects\react-dashboard\node_modules\bootstrap-loader\loader.js:1:1)
    at Module._compile (module.js:398:26)
    at Object.Module._extensions..js (module.js:405:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Module.require (module.js:354:17)

Adding bootstrap-loader to an entry point does not work:

entry: ['bootstrap-loader', './src/client.js'],

Refs: kriasoft/react-starter-kit#179

Using url() in scss throws parse failed error

I'm using bootstrap-loader for the first time and it is working amazingly. Or it was, until I've tried to add a background using url(...) syntax, now I can't get it to work.

Every time I try to compile it, I get this error:

ERROR in ./src/assets/image.png
    Module parse failed: [project-root-path]/src/assets/image.png Line 1: Unexpected token ILLEGAL
    You may need an appropriate loader to handle this file type.
    (Source code omitted for this binary file)
     @ ./~/css-loader!./~/postcss-loader!./~/resolve-url-loader!./~/sass-loader?sourceMap!./~/bootstrap-loader/lib/bootstrap.styles.loader.js!./~/bootstrap-loader/no-op.js 6:156925-156967

I've tried with adding resolve-url, but it didn't work. I have installed all the dependencies listed in installation section.

I don't even need the resolving url part, for now it would be fine if just the url() worked like it's expected to work in regular CSS code.

List of styleLoaders:

styleLoaders:
  - style
  - css
  - resolve-url
  - postcss
  - sass

Is it possible to use bootstrap-loader without jQuery?

I am using a very simple webpack config to use bootstrap-loader:

const path = require('path');
const autoprefixer = require('autoprefixer');

module.exports = {

  entry: [
    'bootstrap-loader',
    './client/javascript/index',
  ],

  output: {
    path: path.join(__dirname, 'client_releases', 'development'),
    filename: 'storytelling.js',
  },

  // devtool: '#cheap-module-eval-source-map',

  module: {
    loaders: [
      { test: /\.jsx?$/, exclude: /(node_modules|bower_components)/, loader: 'babel' },
      { test: /\.css$/, loaders: ['style', 'css', 'postcss'] },
      { test: /\.scss$/, loaders: ['style', 'css', 'postcss', 'sass'] },
      { test: /\.woff2?(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: 'url?limit=10000' },
      { test: /\.(ttf|eot|svg)(\?[\s\S]+)?$/, loader: 'file' },
    ],
  },

  postcss: [autoprefixer],

};

This leaves me with the error

Uncaught ReferenceError: jQuery is not defined

We know how en-vogue it is not to use jQuery and in fact we really don't need it (or want it). Is it possible to use bootstrap-loader without jQuery?

Babel polyfills missing

Hi guys,

I just tried cloning and trying out the examples and run into an issue.

It seems that areas of your code are using ES6 features that require babels polyfills which are not included, for example the Array.prototype.find method, examples of which are used here:

https://github.com/shakacode/bootstrap-loader/blob/master/src/utils/processStyleLoaders.js#L28-L31

If I add the babel polyfills as a precursor to using bootstrap-loader in my webpack config file it works.

Is this something you guys have seen before?

Thanks,
Chris Temple

How would you use bootstrap styles to build css module styles

First of all - this loader is awesome. Thanks for putting it together! This is more of a question than an issue. I am currently using CSS modules to style React components. Many of these components will be modified versions of Bootstrap's component styles. Currently, I just add the Bootstrap class names in the component as well as an extra class from the CSS module to tweak its style. This has a couple of disadvantages:

  • JSX markup is littered with verbose template strings like:
className={`col-sm-6 col-md-2 col-lg-3 ${specialStyleFromModule}`} / 

...In other words, no semantic class names

  • Can't access the global Bootstrap SCSS variables

I haven't been able to figure out how to use SCSS @extend on the global bootstrap styles within this context. I can imagine that there might be a really good reason NOT to couple component CSS modules with global Bootstrap styles like this...

Is there a way to tweak the loader config or some other trick I'm not thinking of to make the Bootstrap vars and classes available in the CSS modules? Is there some other way of thinking about this that I'm missing? Any help would be greatly appreciated! Here is my loader config if that helps:

{
module: {
    loaders: [
      { test: /\.jsx$/, loader: 'react-hot!babel?presets[]=react,presets[]=es2015', include: path.join(__dirname, 'src') },
      { test: /\.js$/, loader: 'babel?presets[]=react,presets[]=es2015', include: path.join(__dirname, 'src') },
      { test: /bootstrap\/dist\/js\/umd\//, loader: 'imports?jQuery=jquery' },
      { test: /\.scss?$/, loader: 'style!css?modules&importLoaders=1&localIdentName=[name]__[local]__[hash:base64:5]!sass', include: path.join(__dirname, 'src') },
      { test: /\.css$/, loader: 'style!css' },
      { test: /\.(woff2?|svg)$/, loader: 'url?limit=10000' },
      { test: /\.(ttf|eot)$/, loader: 'file' }
    ]
  }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.