const path = require("path"); const HtmlWebpackPlugin = require("html-webpack-plugin"); module.exports = { mode:"production", // development是开发模式 // node无 // production 生产模式 // entry:"", 单个入口 默认index.js // 注意清dist // 对象写法 // entry:{ // text:"./src/text.js", // text2:"./src/text2.js" // }, // 数组写法 // entry:[ // "./src/text.js", // "./src/text2.js" // ], output:{ // filename:"file.js", //指定打包后的文件名称 clean:true, //自动删除旧的文件,生成新的打包文件 // path:path.resolve(__dirname,"hello") , //指定打包后的文件 hello文件夹(自己创建的已有的文件夹) // 如果有多个文件 // filename:"[name.js]" //此时entry用对象写法,数组写法容易合并只生成一个文件 }, module:{ rules:[ { test:/\.css$/, //匹配正则 use:[ {loader:"style-loader"}, {loader:"css-loader"}, ] //执行顺序是先后往前,先css转换在style展示 } ] }, plugins: [new HtmlWebpackPlugin({ title: "打包工具webpack", })], }