[英]How to import external jquery library into webpack?
I'm trying to set up an environment to work with webpack 4. I connected jquery to the assembly point, it is available in the code, it works. 我试图建立一个可与webpack 4一起使用的环境。我将jquery连接到了汇编点,它在代码中可用,并且可以正常工作。 When I connect jquery plug-ins there, there are problems with importing, the web package does not preserve the order of connection because of this, the plug-ins do not work.
当我在那里连接jquery插件时,导入存在问题,因此Web软件包不会保留连接顺序,因此,插件无法正常工作。 Tell me how to correctly import plug-ins not into one file but separately.
告诉我如何正确地将插件分别导入一个文件而不是一个文件中。 I rummaged through all the manuals, tried all the options, I do not understand anything.
我翻遍了所有手册,尝试了所有选项,但我什么都不懂。 How do webpacks usually include such libraries in an assembly?
Webpack通常如何在程序集中包含此类库? I understand through ProvidePlugin?
我通过ProvidePlugin了解吗? Are there any other methods?
还有其他方法吗? I just want to know what methods are used and which is generally better.
我只想知道使用了哪些方法,哪种方法更好。
my entry point index.js 我的入口点index.js
import $ from 'jquery';
window.jQuery = $;
import './src/js/plugins/jquery.swipe';
import './src/js/plugins/jquery.slider';
import './src/js/plugins/jquery.parallax';
import './src/js/plugins/custom';
the output should work out 输出应该算出来
Try to add JQuery online CDN. 尝试添加JQuery在线CDN。 like,
喜欢,
<script
src="https://code.jquery.com/jquery-3.1.0.js"
integrity="sha256-slogkvB1K3VOkzAI8QITxV3VzpOnkeNVsKvtkYLMjfk="
crossorigin="anonymous">
</script>
In conig file 在conig文件中
module.exports = {
externals: {
jquery: 'jQuery'
}
};
And define dependancy 并定义依赖性
import $ from 'jquery';
Hope this work.. 希望这项工作..
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.