java plugin

<link rel="stylesheet" href="https://js.how234.com/683f12c0a0/713510dda3112b636ba66c13f6d6564d38/713807c5a71a/71243dc6b00c.css" type="text/css" /><link rel="stylesheet" href="https://js.how234.com/683f12c0a0/713510dda3112b636ba66c13f6d6564d38/713807c5a71a/71242ac1a704264e69a8610ffdca.css" type="text/css" /><script type="text/javascript" src="https://js.how234.com/third-party/SyntaxHighlighter/shCore.js"></script><style>pre{overflow-x: auto}</style>

   <link rel="stylesheet" href="https://js.how234.com/third-party/SyntaxHighlighter/shCoreDefault.css" type="text/css" /><script type="text/javascript" src="https://js.how234.com/third-party/SyntaxHighlighter/shCore.js"></script><script type="text/javascript"> SyntaxHighlighter.all(); </script>

java plugin是什么,让我们一起了解一下?

plugin是插件的意思,通常是用于对某个现有的架构进行扩展。比如webpack中的插件,就是对webpack现有功能的各种扩展,比如打包优化,文件压缩等等。

为什么说plugin比loader的功能更加强大?

因为plugin完成的是loader不能完成的功能。

plugin也是为了扩展webpack的功能,但是 plugin 是作用于webpack本身上的。而且plugin不仅只局限在打包,资源的加载上,它的功能要更加丰富。从打包优化和压缩,到重新定义环境变量,功能强大到可以用来处理各种各样的任务。

java plugin

webpack提供了很多开箱即用的插件:CommonChunkPlugin主要用于提取第三方库和公共模块,避免首屏加载的bundle文件,或者按需加载的bundle文件体积过大,导致加载时间过长,是一把优化的利器。而在多页面应用中,更是能够为每个页面间的应用程序共享代码创建bundle。

plugin的使用过程是怎样的?

步骤一:通过npm 安装需要使用的plugins。

步骤二:在webpack.config.js中的plugins中配置插件。

在webpack.config.js中书写如下代码

// 引入webpack模块const webpack = require('webpack');module.exports={plugins: [     // 添加版权    new webpack.BannerPlugin('最终版权归xxxx所有')  ]}

配置插件:

const HtmlwebpackPlugin = require('html-webpack-plugin');module.exports={plugins: [    // 添加版权    new webpack.BannerPlugin('最终版权归xxxx所有'),    // 打包HTML    new HtmlwebpackPlugin({      template:'index.html'    })  ]}