0

Using Express, Webpack and Bootstrap. I'm using css-loader for stylesheets. Here's my webpack.config.js:

const path = require("path");

config = {
    "entry": "./modules/entry.js",
    "output": {
        "path": path.resolve(__dirname, "public"),
        "filename": "bundle.js"
    },
    "module": {
        "rules": [
            { "test": /\.css$/, "use": "css-loader"}
        ]
    }
}

module.exports = config

Entry.js only requires the stylesheets:

require("bootstrap")
require("glyphicons")

I put all these files in my public folder which I serve using app.use(express.static("public"))

And in my index.html I have a script tag:

<script src="./public/bundle.js" type="text/javascript">

Using bootstrap classes (or glyphicons) on my html does nothing.

Jakov
  • 720
  • 1
  • 12
  • 29

2 Answers2

1

Try this for using bootstrap with webpack

https://github.com/shakacode/bootstrap-loader

1

The require('bootstrap') will only import javascript in your case, to import CSS you need to use require('bootstrap/dist/css/bootstrap.min.css'), or in case of using non-compiled bootstrap version, you'll need more loaders.

You can find more info and configuration sample at official documentation page here