1️⃣ 安装
npm init
npm i webpack@4 webpack-cli@3 -D
npm install --save-dev clean-webpack-plugin
npm i --save-dev html-webpack-plugin@4
1️⃣ package.json
{
......
"scripts": {
"build": "webpack --mode=production",
"dev": "webpack --mode=development"
},
......
}
1️⃣ webpack.config.js
const path = require("path");
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
mode: 'development',
entry: './src/index.js',
output: { path: path.resolve(__dirname, 'builder'),filename: 'build.js' },
module: {
rules: []
},
plugins: [
new CleanWebpackPlugin(),
new HtmlWebpackPlugin({
template: "./src/index.html",
filename: "index.html",
title: "测试HTMl",
}),
],
devtool: 'cheap-module-eval-source-map',
}
上一篇:Webpack 打包配置
下一篇:Webpack 初步认识