1. yarn add file-loader url-loader
    1. const path = require("path");
    2. const HtmlWebpackPlugin = require("html-webpack-plugin");
    3. const {CleanWebpackPlugin} = require("clean-webpack-plugin")
    4. module.exports = {
    5. entry:path.join(__dirname,'src/main.js'),
    6. output:{
    7. filename:"bundle.js",
    8. path:path.join(__dirname,"dist")
    9. },
    10. module:{
    11. rules:[
    12. {
    13. test:/\.css$/,
    14. use:['style-loader','css-loader']
    15. },
    16. ++
    17. {
    18. test:/\.(gif|jpg|png|svg|jpeg)$/,
    19. use:[
    20. {
    21. loader:'url-loader',
    22. options:{
    23. limit:1024
    24. }
    25. }
    26. ]
    27. }
    28. ]
    29. },
    30. plugins:[
    31. new CleanWebpackPlugin(),
    32. new HtmlWebpackPlugin({
    33. template:path.join(__dirname,'public/index.html')
    34. })
    35. ],
    36. mode:"development"
    37. }