Webpack import bootstrap .js and .css
You need to do the following things to make it work:
- In your webpack config file,
resolve
section, make sure your bootstrap css file path is included.
As an example:
var bootstrapPath = path.join( __dirname, 'development/bower_components/bootstrap/dist/css');
Then in your webpack config object:
resolve: { alias: { jquery: path.join(__dirname, 'development/bower_components/jquery/jquery') }, root: srcPath, extensions: ['', '.js', '.css'], modulesDirectories: ['node_modules', srcPath, commonStylePath, bootstrapPath]}
- Make sure you have style loader and css loader. E.g.
loaders:[{ test: /\.css$/, loader: "style-loader!css-loader" }]
- Use it in your js file
require('bootstrap.min.css');
Just use the less plugin and declare them properly...
// Webpack file{ test: /\.less$/, loader: "style-loader!css-loader!less-loader"},// I have to add the regex .*? because some of the files are named like... fontello.woff2?952370{ test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|ico)(\?.*)?$/, loader: 'url?limit=50000'}// Less file@import '~bootstrap/less/bootstrap';
I am still working on the JS but I will let you know soon :-)