const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
mode: 'production',
entry: './src/b.js',
// entry: ['./src/a.js', './src/b.js'],
// entry: {
// hi:'./src/b.js',
// ha:'./src/a.js'
// }
output: {
// clean: true, // 清楚打包文件中的其他文件
filename:'[name]-[id]-[hash].js', //输出文件名字
// path:path.resolve(__dirname,'news') // 打包文件夹输出
},
module: {
rules: [
{
test: /\.css$/i,
use: ['style-loader', 'css-loader'],
},
{
test: /\.(png|svg|jpg|jpeg|gif)$/i,
type: 'asset/resource',
},
{
test: /\.m?js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
},
},
},
],
},
plugins: [new HtmlWebpackPlugin({ template: './src/index.html' })],
devtool: 'inline-source-map'
}