Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get bootstrap by NPM and include to html

Generally I am using CDN (or nuget) for including Bootstrap or other client side libraries to my website

Recently I read about NPM/Bower and other modern package-management tools, and decided to try

After some time of surfing and investigating I am now completely puzzled, how to just download and include bootstrap distrib css/js files to my page like it was....

1 st Try, I install bootstrap with NPM, it downloads whole Bootstrap with all sources/modules and etc to the node_module directory... well, I found distributions in node_modules/Bootstrap/dist folder

now questions:

  • Should I link node_modules/Bootstrap/dist/ css and js files to my site?
  • If yes, should I then deploy whole node_modules folder with website?
  • if No, and I know that npm package is modular and bla bla bla and should be included by require("bootstrap") than lots of other questions

    • is require("bootstrap") node js or some oter js function?
    • should I include some other node packages or js files in order require("bootstrap") to work
    • where should I write require("bootstrap") in html in script tag? create some js and include it or what?

2 nd try, Ok than I understand that npm might be package management for NodeJs server side, and got bower... but again it downloads the same files to another folder bower_components and again same questions...

like image 854
Arsen Mkrtchyan Avatar asked Jan 21 '26 19:01

Arsen Mkrtchyan


1 Answers

As you mentioned, bower works well for this use case. Change the destination of the bower_components directory as described here How to change bower's default components folder?

then include as you normally would. Do not use the require function since that is for nodejs server side only.

like image 100
cs01 Avatar answered Jan 25 '26 00:01

cs01