const path = require("path");
const HtmlWebpack = require('html-webpack-plugin');
const { devtools } = require("vue");
// 抛出
// export const a  =10;
module.exports = {
  mode: "production", //development
  // 入口:
  // 1.单文件
  // entry:"./src/a1.js",
  // 2.多文件
  // entry: ['./src/a1.js','./src/a2.js'],
  // entry:{
  //     first:'./src/a1.js',
  //     second:'./src/a2.js'
  // },
  // 输出
  output: {
    // 自动删除旧的打包文件 生成新的打包文件
    clean: true,
    // 指定打包后的文件名称
    // filename:"[name]-[id]-[hash].js",
    // filename:"happy.js",
    // 指定打包后的文件夹
    // path:path.resolve(__dirname,'dist')
  },
  // loader
  module:{
    rules:[
        {
            test:/\.css$/,
            use: ["style-loader","css-loader"]
        },
        {
          test:/\.(png|jpg|jpeg|gif)$/,
          type: 'asset/resource'
        },
        {
          test: /\.m?js$/,
          exclude: /(node_modules|bower_components)/,
          use: {
            loader: 'babel-loader',
            options: {
              presets: ['@babel/preset-env'],
            },
          },
        },
    ]
  },
  // 插件
  plugins:[new HtmlWebpack({
    title:"你好啊",
    template: "./src/demo.html"
  })],
  // // 映射源码
  devtool:"inline-source-map"
};