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)