简单的asset例子,指定类型为asset之后,webpack会自动将文件拷贝的dist指定目录。无需其他第三方loader。

    1. module.exports = {
    2. output: {
    3. assetModuleFilename: "images/[hash][ext]"
    4. },
    5. module: {
    6. rules: [
    7. {
    8. test: /\.(png|jpg|svg)$/,
    9. type: "asset"
    10. }
    11. ]
    12. },
    13. experiments: {
    14. asset: true
    15. }
    16. };