webpack - 将引导程序添加到 webpack。为什么第二种方法不起作用
问题描述
只有它对我有用
在 js scrypts 中添加:
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 构建中使用的其他 $ 示例。有人可以解释一下吗?
有这个构建回购克隆
解决方案
推荐阅读
- c# - CsvWriter 中的 IndexOutOfRangeException
- batch-file - 将任意长度的前缀应用于带有批处理文件的文件目录
- r - 卡方比较一个参考组与另外两个组
- javascript - 从汇总 dist 文件中删除绝对文件路径名
- css - 为什么输入字段比它的父 div 更宽?
- python - 从 Azure Functions 调用时,Django API 引发 403 错误
- android - 如何使用 LiveData 将不同数据类型的多个数据从 ViewModel 传递到 Activity/Fragment
- c# - C# 模式匹配任务
并获得它的价值 - python - 使用 str(df) 后如何取回 DataFrame?
- python - 全局禁用 TensorFlow 断言?