问题描述
因此,在完成工作之后,我在css文件的base64中将图像编码为2.8mb((((
这是我的gulpfile:
const path = {
stylus: {
src: './src/stylus/**/*.styl',dest: './build/styles',},build: {
dest: 'build/**'
}
}
function stylusTask() {
return src(path.stylus.src)
.pipe(plumber())
.pipe(stylus({
use: nib(),import: ['nib'],compress: true
}))
.pipe(dest(path.stylus.dest))
}
解决方法
您可以将触控笔配置为仅对小于指定限制的图像进行编码。超过该限制的图片的网址将不会被修改。
在此示例中,仅对小于2000字节的图像进行编码:
function stylusTask() {
return src(path.stylus.src)
.pipe(plumber())
.pipe(stylus({
use: nib(),import: ['nib'],compress: true,define: {
url: require('stylus').url({
limit:2000
})
}
}))
.pipe(dest(path.stylus.dest))
}
有关url函数的更多信息,请参见以下文档: https://stylus-lang.com/docs/functions.url.html