Webpack-2 externals how to download boot file from cdn

I created my webpack configuration file and it works great. I want to use externals to load some libs from a CDN:

externals:{
        jQuery: 'jquery',
        $: 'jquery',
        moment: "moment",
        Highcharts:'highcharts',
        tether: 'tether',
        Tether: 'tether',
        'window.Tether': 'tether'
        }

However, I cannot load the bootloader. I tried bootstrap:'bootstrap' bootstrap:true, but it does not work. I tried importand requirein my file. When I need jquery var $ = require('../../../node_modules/jquery/dist/jquery');bootstrap modal gets an error, and when I request a request jquery, I see an error jquery.

So far I have no idea how to solve this.

+4
source share
1 answer

, (. bootstrap/js/src/index.js:

export {
  Util,
  Alert,
  Button,
  Carousel,
  ...
}

, , :

webpackConfig.externals = {
    jquery: '$',
    bootstrap: {
        Util: 'Util',
        Alert: 'Alert',
        Button: 'Button',
        Carousel: 'Carousel',
        Collapse: 'Collapse',
        Dropdown: 'Dropdown',
        Modal: 'Modal',
        Popover: 'Popover',
        Scrollspy: 'Scrollspy',
        Tab: 'Tab',
        Tooltip: 'Tooltip'
    },
    ...
}
0

Source: https://habr.com/ru/post/1677814/


All Articles