Webpack Plugin Plugin

Source: Internet
Author: User
Recently you have seen the use of Webpack plug-ins to sum up a, Html-webpack-plugin plug-ins

Documents: Https://github.com/jantimon/html-webpack-plugin#configuration
Function:: After compiling, change the old JS name in our HTML file
Usage:

NPM Install--save-dev Html-webpack-plugin

Webpack.config.js configuration:

Const Htmlwebpackplugin = require (' Html-webpack-plugin ');

Module.exports = {
 plugins:[
      new Htmlwebpackplugin ({
        title: ' Output Management '/title name
      }),
   ]
}
Second, Clean-webpack-plugin Plug-ins

Documents: Https://github.com/jantimon/html-webpack-plugin (Https://www.npmjs.com/package/clean-webpack-plugin)
Function: Clear past compiled code
Usage:

NPM Install Clean-webpack-plugin--save-dev

Webpack.config.js

Const Cleanwebpackplugin = require (' Clean-webpack-plugin ');
Module.exports = {
  plugins:[
      new Cleanwebpackplugin ([' Build/js '])//clear path Build/js
   ]
}
Third, Extract-text-webpack-plugin Plug-ins

Documents: Https://github.com/webpack-contrib/extract-text-webpack-plugin
function: Separate CSS styles and introduce HTML in link mode
Usage:

NPM Install--save-dev Extract-text-webpack-plugin

Webpack.config.js

Const Extracttextplugin = require (' Extract-text-webpack-plugin ');

 module:{
      rules:[
          {
            test:/\.css$/,
            use:ExtractTextPlugin.extract ({use
              : ' Css-loader '
            })
          },
          {
            test:/\.less$/,
            use:ExtractTextPlugin.extract ({
              use:[' css-loader ', ' Less-loader ') }
          },
      ]
   },
   plugins:[ 
      new Extracttextplugin (' Styles.css ')
   ]
Four, automatic loading module provideplugin

To introduce jquery as a column

 Const Webpack = require (' Webpack '); plugins:[new Webpack. Provideplugin ({$: ' jquery ', jquery: ' jquery ', ' window.jquery ': ' jquery ', ' window.$ ': ' Jqu Ery '})] 

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.