錯誤詳情
在html文件中添加<img>標簽,並寫入src屬性后打包報錯
ERROR in Error: C:\Users\12203\Desktop\webpack-practice\05_打包圖
片資源\src\index .html:97
/******/ if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser");
^
Error: Automatic publicPath is not supported in this browser
解決方法
在webpack.config.js
中output
寫入屬性publicPath:'./'
即可。
一個錯誤的嘗試方法
我試圖將<img>的src屬性的./刪去,但依然報錯。嚴格寫入publicPath即可。
打包后的文件目錄
│ webpack.config.js
│
├─dist
│ │ bundle.js
│ │ index.html
│ │
│ └─img
│ 2e0f10b356.jpg
│ 3fb3b9239a.jpg
│ 7cbde3b492.jpg
│ 88e40a8cf6.jpeg
│
└─src
│ index.html
│ index.less
│ main.js
│
├─img
│ 19300260829801133655476327752_950.jpg
│ 20150228172529_yZALv.jpg
│ 20160607122101_At5zX.jpeg
│
└─img2
└─images
12942076507360.jpg