webpack.config.js 838 B

1234567891011121314151617181920212223242526272829303132
  1. /**
  2. * loader: 1下载 2使用
  3. * plugins:1下载 2引入 3使用
  4. */
  5. const {resolve} = require('path')
  6. const htmlWebpackPlugin = require('html-webpack-plugin')
  7. module.exports = {
  8. entry: './src/index.js',
  9. output:{
  10. filename: 'js/built.js',
  11. path: resolve(__dirname,'build')
  12. },
  13. module:{
  14. rules:[
  15. ]
  16. },
  17. plugins:[
  18. // html-webpack-plugin
  19. // 默认创建一个空的html文件 自动引入打包输出的所有资源(js/css)
  20. // 需要有解构的html文件
  21. new htmlWebpackPlugin({
  22. // 复制该文件,并自动引入打包输出的所有资源
  23. template: './src/index.html'
  24. })
  25. ],
  26. mode:'production',
  27. externals:{
  28. //忽略 库名 -- 包名
  29. jquery: 'jQuery'
  30. }
  31. }