WEBPACK3 Study Notes (i)

Source: Internet
Author: User

First, prepare

--NPM Init, initializing Package.json

--NPM Install Webpack--save-dev

Project root new webpack.config.js, for webpack packaging configuration

Second, packaging configuration

varPath = require (' path ');varWebpack = require (' Webpack '));varHtmlplugin = require (' Html-webpack-plugin ')); Module.exports={entry: {index1:'./index.js ', Index2:'./index2.js '}, Output: {path:path.resolve (__dirname,' Dist '), FileName:' Js/[name]-[chunkhash].bundle.js '}, plugins: [NewHtmlplugin ({title:' Webpack1234 ', FileName:' Webpack.demo.html ', Template:' Index.html ',        }) ]};

The introduction of the--webpack module is similar to that of CMD,COMMONJS, so it is possible to use require () directly to introduce relevant modules

1, Entry (three kinds of formats)

Single string: Entry: './main.js '

Array of strings: entry: ['./main.js ', './main2.js ']

Object: Entry: {

A: './main.js ',-------->trunkname: Path

B: './main2.js '-------->trunkname: Path

}

2. Output

{

Path: '-----absolute path

FileName: ' Bundle.js '

},

If the entry has multiple trunks, filename should be: ' [name].bundle.js '

WEBPACK3 Study Notes (i)

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.