I'm trying to load up bootstrap using webpack. The css works just fine, but the glyphicons seem to break by showing a square (see below). No console errors
module.exports = {
entry: "./public/app/main.js",
output: {
path: __dirname + '/public/dist/',
filename: "bundle.js"
},
module: {
loaders: [
{
test: /\.css$/,
loader: "style-loader!css-loader"
},
{
test: /\.less$/,
loader: "style!css!less"
},
{
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: "url-loader?limit=10000&mimetype=application/font-woff" },
{
test: /\.(ttf)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: "url-loader?limit=10000&mimetype=application/octet-stream"
},
{
test: /\.(eot)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: "file"
},
{
test: /\.(svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: "url-loader?limit=10000&mimetype=image/svg+xml"
},
]
},
node: {
fs: "empty"
}
};
<i class="done-icon glyphicon glyphicon-ok"></i>
What can I use instead of Glyphicons? Free Alternatives to Glyphicons You can use both Font Awesome and Github Octicons as a free alternative for Glyphicons. Bootstrap 4 also switch from Less to Sass so you might integrate the font's Sass (SCSS) into your build process, to create a single CSS file for your projects.
Bootstrap 4 does not have its own icon library (Glyphicons from Bootstrap 3 are not supported in BS4). However, there are many free icon libraries to choose from, such as Font Awesome and Google Material Design Icons.
Glyphicons can be used in text, buttons, toolbars, navigation, forms, etc.
What are Glyphicons? Glyphicons are icon fonts which you can use in your web projects. Glyphicons Halflings are not free and require licensing, however their creator has made them available for Bootstrap projects free of cost.
Try this:
loaders: [
{
test: /\.css$/,
loader: 'style-loader!css-loader'
},
{
test: /\.png$/,
loader: 'url-loader?limit=100000'
},
{
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'url-loader?limit=10000&mimetype=application/font-woff'
},
{
test: /\.(ttf|otf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?|(jpg|gif)$/,
loader: 'file-loader'
}
]
and your javascript (assuming npm and modules):
import 'bootstrap/dist/css/bootstrap.css';
import 'bootstrap/dist/css/bootstrap-theme.css';
Just a heads up that webpack is going to put the font files in the same directory as your bundle.js
file so you may need to ensure that your index.html
file is also copied to your dist
folder so the path references are correct.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With