Answer the question
In order to leave comments, you need to log in
How to correctly substitute the path to images in webpack?
Why does webpack incorrectly substitute the path to images? (substituting all paths, didn't help)
src
--assets
--pug
----pages // calling here
Module not found: Error: Can't resolve './.../assets/iphone.png' in 'C :\project\src\pug\pages':img(src=".../assets/iphone.png")
{
test: /\.(pug|jade)$/,
exclude: /(node_modules)/,
use: [
'html-loader',
{
loader: 'pug-html-loader',
options: {
data: {}
}
}
]
},
{
test: /\.(jpe?g|png|gif|svg)$/i,
use: [
{
loader: 'file-loader',
options: {
emitFile: true,
name: 'images/[name]-[sha512:hash:base64:12].[ext]'
}
}
]
}
Answer the question
In order to leave comments, you need to log in
'. /.../assets/iphone.png ' there are three dots (should be two). If it doesn't work, try removing the ./
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question