Answer the question
In order to leave comments, you need to log in
How to get rid of long relative paths in require src in pug templates with webpack setting?
How to avoid view paths in pug/jade template files:
img.css_class(src=require("../../../img/spinner.png"))
img.css_class(src=require("./spinner.png"))
module: {
rules: [
{
test: /\.(jade|pug)$/,
use: [
{
loader: 'pug-loader',
options: {
self: true,
globals: true,
pretty: true,
compileDebug: true
}
}
]
},
{
test: /\.(jpe?g|png|gif|svg|ico)$/i,
use: [
{
loader: 'file-loader',
options: {
name: '[name]-[hash].[ext]',
outputPath: 'src/img/',
publicPath: 'src/img/'
}
},
{
loader: 'image-webpack-loader',
options: {
mozjpeg: {
progressive: true,
quality: 65
}
}
}
]
}
]
}
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