webpack图像加载器出错

时间:2017-07-03 05:22:01

标签: css angular webpack jhipster

我的网站配置是 -

{
test: /\.(jpe?g|png|gif|svg|woff2?|ttf|eot)$/i,
loaders: ['file-loader?hash=sha512&digest=hex&name=content/[hash].[ext]']
}, 

收到以下错误:

ERROR in ./~/css-loader!./~/postcss-loader!./~/sass-
loader/lib/loader.js!./src/main/webapp/content/scss/vendor.scss
Module not found: Error: Can't resolve './images/color.png' in 
'D:\Work\Personal\Projects\CashbackCalculator\src\main\webapp\content\scss'
@ ./~/css-loader!./~/postcss-loader!./~/sass-
loader/lib/loader.js!./src/main/webapp/content/scss/vendor.scss 6:284192-
284221
@ ./src/main/webapp/content/scss/vendor.scss
@ ./src/main/webapp/app/vendor.ts
@ dll vendor

1 个答案:

答案 0 :(得分:3)

如果您有images文件夹包含所有图片,则可以尝试按照以下代码加载图片:

test: /\.(jpe?g|png|gif|svg|woff2?|ttf|eot)$/i,
use: [
         { loader: "url-loader?name=/images/[name].[ext]" },
         { loader: "image-webpack-loader" }
     ]

对我有用!