1、如果是js创建img元素,那么要用load(之前的课程)
    2、如果是静态资源:(网页上已经写死了)
    webpack.config:

    1. const { CleanWebpackPlugin } = require("clean-webpack-plugin")
    2. const HtmlWebpackPlugin = require('html-webpack-plugin')
    3. const CopyPlugin = require('copy-webpack-plugin');
    4. module.exports = {
    5. mode: "development",
    6. devtool: "source-map",
    7. output: {
    8. filename: "scripts/[name].[chunkhash:5].js"
    9. },
    10. plugins: [
    11. new CleanWebpackPlugin(),
    12. new HtmlWebpackPlugin({
    13. template: "./public/index.html"
    14. }),
    15. new CopyPlugin([
    16. { from: "./public", to: "./" } //复制规则,to指的就是相对目录
    17. ])
    18. ]
    19. }

    主要指令:

    1. copy-webpack-plugin

    效果图:
    image.png