将引导程序添加到webpack。为什么第二种方式不起作用

时间:2019-10-24 12:37:32

标签: webpack bootstrap-4

这是对我有效的唯一方法

在js scrypt中添加:

import $ from 'jquery';
global.jQuery = $;
global.$ = $;

import Popper from 'popper.js'
global.Popper = Popper

import 'bootstrap'

// there $.fn defined anyway
// and in chrome console too (in first way)

第二种方式(无效):

// ! comment this strings
// import $ from 'jquery';
// global.jQuery = $;
// global.$ = $;
// after bootstrap importing add

 console.log($.fn) // Object, defined   
 // past it in console after execution - it will undefined

// add in config
plugins: [
     new webpack.ProvidePlugin(
        {
            $: 'jquery',
            jQuery: 'jquery',
            'window.jQuery': 'jquery',
            'global.jQuery': 'jquery',
            'global.$': 'jquery',
        },
     ),
...

但是,如果要以更低的方式执行操作,我不知道为什么在scrypt的控制台结束时,$。fn未定义。它看起来像在控制台和Webpack构建中使用的$的其他示例。 有人可以解释吗?

build repo要克隆

0 个答案:

没有答案
相关问题