How to load images through webpack when using HTMLWebpackPlugin?

后端 未结 4 805
礼貌的吻别
礼貌的吻别 2020-12-29 20:38

I am using HTMLWebpackPlugin and in my template I have an img tag:


If you notice, here I am using a r

4条回答
  •  没有蜡笔的小新
    2020-12-29 21:16

    You should use the CopyWebpackPlugin.

    const CopyWebpackPlugin = require('copy-webpack-plugin');

    plugins:[
        ....
        new CopyWebpackPlugin([
             {from:'./src/assets/images',to:'images'} 
         ]),
        ....
    ]
    

    This is copy the src/assets/images to your `distfolder/images'.

提交回复
热议问题