Webpack Framework Knowledge Finishing--plugins

Source: Internet
Author: User

5 Plugins Plug-in

5.1 Our Nodejs system is full of plug-ins, Webpack is also based on a variety of plug-ins to work properly, plug-ins for Webpack is a very important pillar to solve the loader can not achieve a lot of things.

Plug - ins:

A plug-in is a JavaScript object with the Apply property, where the Apply property is called by Webpack compiler and the compiler object can be accessed throughout the compilation life cycle;

functionLogonbuildwebpackplugin(){}; Pass a function as a plug-in through Function.prototype.apply, in the configuration so that you can inline the custom plugin Logonbuildwebpackplugin. prototype. Apply=function(Compiler){Compiler.Plugin(' Run ',function (Compiler{console log ( "Hello,let ' s start!        "callback (}) } 5.2 Plug-ins can carry parameters/options, and the  Plugins  property must be passed into the  new  instance in the Webpack configuration, as shown in the following code. 
/span>
Const Htmlwebpackplugin=Require(' Html-webpack-plugin ');      Const Webpack=Require(' Webpack ');      ...Const CONFIG={Entry: ...Output:{     ...      }, module{... < Span class= "token string" > }[new webpack .optimize ( , //plugin installed via NPM  
< Span class= "token punctuation" >< Span class= "token punctuation" > new htmlwebpackplugin{template}            //built-in plug-in  
< Span class= "token punctuation" >  ]}; 
Module.exports = Config
        

Webpack Framework Knowledge Collation--plugins

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.