新建空文件夹:cmd

npm init -y
cnpm i -D webpack webpack-cli

文件夹和文件

src(文件夹)

index.html
<script src="test.js">
test.js
console.log(123)
安装插件(生成html):HtmlWebpackPlugin------>https://webpack.js.org/plugins/html-webpack-plugin/
cnpm install --save-dev html-webpack-plugin
webpack.config.js
var HtmlWebpackPlugin=require('html-webpack-plugin');

module.exports= {

entry: './src/main.js',

plugins: [newHtmlWebpackPlugin()]

};
运行打包命令:
webpack src/test.js

生成文件夹和文件

dist(文件夹)

index.html
main.js

webpack.04-entry points 配置


B͜a͜r͜a͜n͜
6 声望0 粉丝