简体   繁体   English

如何在Webpack中使用jquery.min做出反应

[英]How to use jquery.min in react with webpack

Can somebody help on how to use jquery.min in React Components. 有人可以帮忙如何在React Components中使用jquery.min。

Using the below increases the bundle size, where core jquery is loaded. 使用以下内容会增加捆绑包大小,并在其中加载核心jquery。

var $ = require('jquery');

I would like to use the minified version of jquery which is less in size. 我想使用较小尺寸的jquery的缩小版本。

You can require the minified version directly: 您可以直接要求缩小版本:

var $ = require('jquery/dist/jquery.min');

However, a more common solution is to run webpack in production mode ( webpack -p ) or use a plugin like uglifyjs-webpack-plugin to minify your entire bundle (including both your own source code and libraries like jQuery) before you deploy your application to production. 但是,更常见的解决方案是在生产模式下以生产模式运行webpack( webpack -p )或使用诸如uglifyjs-webpack-plugin之类的插件来最小化整个捆绑包(包括您自己的源代码和jQuery之类的库)生产。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM