webpack.config.js 810 B

123456789101112131415161718192021222324252627
  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. plugins:[
  11. new HtmlWebpackPlugin({
  12. template:'./src/index.html',
  13. minify:{
  14. //去除空格
  15. collapseWhitespace:true,
  16. //去除注释
  17. removeComments:true
  18. }
  19. }),
  20. new EsLintPlugin({
  21. extensions: ['js', 'json', 'coffee'],
  22. //exclude: '/node_modules/', //default
  23. fix:true
  24. })
  25. ],
  26. mode:'production' //生产环境下会自动压缩
  27. }