Answer the question
In order to leave comments, you need to log in
How to properly set outputPath for file-loader?
I connected the file-loader to the build process in webpack in this way.
{
test: /\.(jpe?g|png|gif|svg)$/,
use: [
{
loader: 'file-loader',
options: {
name: "[name].[ext]",
outputPath: "img",
useRelativePath: true,
}
},
{
loader: 'image-webpack-loader',
options: {
mozjpeg: {
progressive: true,
quality: 65
},
optipng: {
enabled: false,
},
pngquant: {
quality: '65-90',
speed: 4
},
gifsicle: {
interlaced: false,
},
svgo: {
enabled: false,
}
}
}
]
},
--src
----img
------logo.jpg
------backgrounds
--------img1.jpg
--------img2.jpg
------icons
--------icon1.svg
--------icon2.svg
--dist
----img
------logo.jpg
------img1.jpg
------img2.jpg
------icon1.svg
------icon2.svg
--dist
----img
------img
--------logo.jpg
------backgrounds
--------img1.jpg
--------img2.jpg
------icons
--------icon1.svg
--------icon2.svg
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