Skip to content

Instantly share code, notes, and snippets.

@thejonwithnoh
Last active January 12, 2017 13:25
Show Gist options
  • Save thejonwithnoh/14aeb59017b8c9103935488a38d48dd2 to your computer and use it in GitHub Desktop.
Save thejonwithnoh/14aeb59017b8c9103935488a38d48dd2 to your computer and use it in GitHub Desktop.
Extending Bootstrap with Webpack

To build, simply copy all files into a directory and run:

npm install

Followed by:

npm run webpack

This gist corresponds to this question on stack overflow

// Application level code of course goes here.
// For instance loading configuration and dependencies.
// In this example, loading all the necessary web components
// will be taken care of by a "components" module.
require('./components');
// This module simply includes all of the web components
// that the application will need.
require('./panel');
require('./tabs');
{
"private": true,
"scripts": {
"webpack": "webpack"
},
"dependencies": {
"bootstrap-sass": "^3.3.7"
},
"devDependencies": {
"css-loader": "^0.26.1",
"extract-text-webpack-plugin": "^1.0.1",
"file-loader": "^0.9.0",
"node-sass": "^4.2.0",
"sass-loader": "^4.1.1",
"style-loader": "^0.13.1",
"webpack": "^1.14.0"
}
}
// This component would bundle all of the templates, stylesheets, and
// scripts needed to create a customized version of bootstrap's panel.
require('./panel.scss');
// Since this component extends the panel functionality of bootstrap,
// it would likely start by extending its "panel" class.
$icon-font-path: "~bootstrap-sass/assets/fonts/bootstrap/";
@import '~bootstrap-sass/assets/stylesheets/bootstrap';
// This component would bundle all of the templates, stylesheets, and
// scripts needed to create a customized version of bootstrap's tabs.
require('./tabs.scss');
// Since this component extends the tab functionality of bootstrap,
// it would likely start by extending its "nav-tabs" class.
$icon-font-path: "~bootstrap-sass/assets/fonts/bootstrap/";
@import '~bootstrap-sass/assets/stylesheets/bootstrap';
var ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = {
entry: {
'app': './app.js',
},
output: {
path: 'output',
filename: 'bundle.js'
},
plugins: [
new ExtractTextPlugin('[name].css')
],
module: {
loaders: [
{ test: /\.scss$/, loader: ExtractTextPlugin.extract('style', ['css', 'sass']) },
{ test: /\.(eot|svg|ttf|woff|woff2)$/, loader: 'file', query: { name: '[name].[ext]'} }
]
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment