要实现“不要打包任何JavaScript,只使用html-webpack-plugin打包HTML”的解决方案,可以按照以下步骤操作:
npm install webpack html-webpack-plugin --save-dev
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
  mode: 'development',
  entry: './src/index.js', // 假设入口文件为src/index.js
  output: {
    path: __dirname + '/dist',
    filename: 'bundle.js' // 此处设置为bundle.js,但不会生成实际的JavaScript文件
  },
  plugins: [
    new HtmlWebpackPlugin({
      template: './src/index.html' // 假设HTML模板文件为src/index.html
    })
  ],
};
  
  My App 
  Hello, World!
"scripts": {
  "build": "webpack --config webpack.config.js"
}
npm run build