webpack.config.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. const {resolve} = require('path')
  2. const HtmlWebpackPlugin = require('html-webpack-plugin')
  3. const EsLintPlugin = require('eslint-webpack-plugin')
  4. module.exports = {
  5. entry:'./src/js/index.js',
  6. output:{
  7. filename:'js/built.js',
  8. path:resolve(__dirname,'build')
  9. },
  10. module:{
  11. rules:[
  12. /**
  13. * webpack5使用eslint-webpack-plugin替代eslint-loader
  14. * webpack4支持以下
  15. * 语法检查 定义写规范 语法错误 eslint-loader eslint
  16. * 只检查源代码,不检查第三方库
  17. * 设置检查规则:
  18. * 在package.json中eslintConfig配置 "extends": "airbnb-base"
  19. * airbnb --> eslint-config-airbnb-base eslint eslint-plugin-import
  20. */
  21. /* {
  22. test: /\.js$/,
  23. exclude: /node_modules/, //排除
  24. loader: 'eslint-loader',
  25. options: {
  26. fix:true //自动修复
  27. }
  28. } */
  29. ]
  30. },
  31. plugins:[
  32. new HtmlWebpackPlugin({
  33. template:'./src/index.html'
  34. }),
  35. new EsLintPlugin({
  36. extensions: ['js', 'json', 'coffee'],
  37. //exclude: '/node_modules/',
  38. fix:true
  39. })
  40. ],
  41. mode:'development'
  42. }