How do I load bootstrap using npm?

后端 未结 7 418
无人共我
无人共我 2021-02-01 15:35

I have a npm project that uses jquery.

var $ = require(\'jquery\');

I also have an index html file that references bootstrap.

  • 7条回答
    •  -上瘾入骨i
      2021-02-01 16:11

      yarn add bootstrap-sass
      yarn add jquery
      

      For style, I use gulp sass which need to include Paths for bootstrap

      @import "bootstrap-sprockets";
      @import "bootstrap";
      
      var sass = require('gulp-sass');
      
      pipe(sass({includePaths: ['node_modules/bootstrap-sass/assets/stylesheets']}).on('error', sass.logError))
      

      For JavaScript, I assign jquery to window.jQuery as bootstrap-sass needed:

      window.jQuery = require('jquery');
      require('bootstrap-sass');
      

    提交回复
    热议问题