does anyone know how I can integrate Bootstrap to nodejs with Express?

0

I am developing an application using nodejs and the Express framework. I want to add Bootstrap to my project in local mode. I added this to my index (having already downloaded Bootstrap)

<script language = "javascript" src = "- / node_modules / bootstrap / dist / js / bootstrap.min.js"> </ script>
<link rel = "stylesheet" href = "./ node_modules / bootstrap / dist / css / bootstrap.min.css" />

I discovered that I have to add this code to my app.js

app.use (express.static (__ dirname + '../node_modules/bootstrap/dist'));

but it does not work either (I have the Bootstrap path in mind and I use '../ modules ...' too. Does anyone know how I can use it or have an example?

    
asked by Diego Izquierdo Dussan 23.04.2018 в 04:46
source

1 answer

0

You should use bootstrap-sass with a task manager like Gulp. It sounds complicated, but it's simple.

You can folder dev where you put the styles and the javascript code and have that transpile to a folder in the front next to the HTML that is called for example statics .

├── dev
|   ├── styles // acá metes los sass
|   └── js

├── statics
|   ├── fonts
|   ├── img
|   ├── css
|   └── js

After that, you would have the calls like this:

<script type="javascript" src="statics/js/bootstrap.min.js"></script>
<link rel="stylesheet" href = "statics/css/bootstrap.min.css" />

Routes using node_modules will work only locally.

    
answered by 23.04.2018 в 17:20