How do I load bootstrap using npm?

后端 未结 7 433
无人共我
无人共我 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条回答
    •  花落未央
      2021-02-01 16:09

      //install expose-loader
      npm install jquery --save  //Installing jquery and saving to package.Json
      npm install bootstrap --save//Installing boostrap and saving to package.Json
      npm install expose-loader --save-dev//Installing expose-loader and saving to package.json
      
      // webpack
      module: {
      rules: [
      {
           test: require.resolve('jquery'),
           loader: 'expose-loader?jQuery!expose-loader?$'
      }
      ]}
      
      // javascript file 
      var $ = require("expose-loader?$!jquery"); 
      require('bootstrap');
      require('jquery.easing');
      

    提交回复
    热议问题