const {resolve} = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const EsLintPlugin = require('eslint-webpack-plugin')
module.exports = {
    entry:'./src/js/index.js',
    output:{
        filename:'js/built.js',
        path:resolve(__dirname,'build')
    },
    module:{
        rules:[
            /**
             * webpack5使用eslint-webpack-plugin替代eslint-loader
             * webpack4支持以下
             * 语法检查 定义写规范 语法错误 eslint-loader eslint
             * 只检查源代码，不检查第三方库
             * 设置检查规则：
             *      在package.json中eslintConfig配置 "extends": "airbnb-base"
             *      airbnb --> eslint-config-airbnb-base eslint eslint-plugin-import
             */
            /* {
                test: /\.js$/,
                exclude: /node_modules/,  //排除
                loader: 'eslint-loader',
                options: {
                    fix:true  //自动修复
                }
            } */
        ]
    },
    plugins:[
        new HtmlWebpackPlugin({
            template:'./src/index.html'
        }),
        new EsLintPlugin({
            extensions: ['js', 'json', 'coffee'],
            //exclude: '/node_modules/',
            fix:true
        })
    ],
    mode:'development'
}