webpack.config.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. const path = require("path")
  2. const HtmlWebpackPlugins = require("html-webpack-plugin")
  3. // node写法
  4. module.exports = {
  5. // development 开发
  6. // production 生产
  7. // mode: 'production',
  8. // entry: "./demo.js"
  9. // entry: ['./src/a.js', './demo.js']
  10. // entry: {
  11. // hi: './src/a.js',
  12. // hello: './src/b.js'
  13. // }
  14. entry: './src/a.js',
  15. // output: {
  16. // filename: 'xxx.js',
  17. // clean: true,
  18. // path: path.resolve(__dirname, 'news')
  19. // }
  20. module: {
  21. rules: [
  22. {
  23. test: /\.css$/i,
  24. use: ['style-loader', 'css-loader'],
  25. },
  26. {
  27. test: /\.(png|svg|jpg|jpeg|gif)$/i,
  28. type: 'asset/resource',
  29. },
  30. ],
  31. },
  32. plugins: [new HtmlWebpackPlugins()],
  33. devtool: 'inline-source-map',
  34. performance: {
  35. maxAssetSize: 100000,
  36. }
  37. }
  38. // 打包命令:yarn webpack
  39. // yarn webpack serve
  40. // yarn webpack serve --open
  41. // png jpg jpeg gif svg 区别