Answer the question
In order to leave comments, you need to log in
What is the correct way to specify Webpack file-loader publicPath with such a file structure?
Structure
:
_
_
_
_
_
_
_
│ ├───img
│ ├───js
│ └───index.html
└───webpack.config.js
index.html
main.sass<img src="img/exapmle.jpg" alt="exapmle">
.home
background: url("../img/example.jpg")
module: {
rules: [
{
test: /\.(jpg|png|svg|gif)$/,
use: [
{
loader: 'file-loader',
options: {
name: '[name].[ext]',
publicPath: 'img',
outputPath: 'img',
useRelativePath: true
}
},
{
loader: 'image-webpack-loader',
...
}
}
]
}
]
},
publicPath: function(url) {
return url.replace(../, '/img/')
},
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question