test imagemin
This commit is contained in:
parent
6b2d8b4400
commit
2c24b17aef
|
@ -2,6 +2,7 @@
|
|||
FROM debian:bookworm-slim
|
||||
RUN apt update
|
||||
RUN apt -y install nodejs npm
|
||||
RUN apt -y install libpng-dev libimagequant-dev
|
||||
RUN mkdir -p /src
|
||||
|
||||
COPY package.json src/package.json
|
||||
|
|
|
@ -6,32 +6,32 @@ import imageminPngquant from 'imagemin-pngquant';
|
|||
|
||||
export default defineNuxtConfig({
|
||||
hooks: {
|
||||
// 'nitro:build:public-assets': async (nitro) => {
|
||||
// console.log(`😈 custom hook imagemin in ${nitro.options.output.publicDir}`)
|
||||
// const output_path = nitro.options.output.publicDir
|
||||
// const filelist = await fs.readdir(output_path, { recursive: true });
|
||||
// for (let index = 0; index < filelist.length; index++) {
|
||||
// const element = filelist[index];
|
||||
// const elementFile = await fs.lstat(`${output_path}/${element}`)
|
||||
// if (element.startsWith('_nuxt')) continue
|
||||
// if (elementFile.isFile()) {
|
||||
// if (element.endsWith('.png')) {
|
||||
// const dest = `${output_path}/${element.split('/').slice(0, -1).join('/')}`
|
||||
// const res = await imagemin([`${output_path}/${element}`], {
|
||||
// destination: dest,
|
||||
// plugins: [
|
||||
// imageminPngquant({
|
||||
// quality: [0.6, 0.8]
|
||||
// })
|
||||
// ]
|
||||
// })
|
||||
// if (res.length) {
|
||||
// console.log(chalk.gray(` compress PNG ${output_path}/${element}`))
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
'nitro:build:public-assets': async (nitro) => {
|
||||
console.log(`😈 custom hook imagemin in ${nitro.options.output.publicDir}`)
|
||||
const output_path = nitro.options.output.publicDir
|
||||
const filelist = await fs.readdir(output_path, { recursive: true });
|
||||
for (let index = 0; index < filelist.length; index++) {
|
||||
const element = filelist[index];
|
||||
const elementFile = await fs.lstat(`${output_path}/${element}`)
|
||||
if (element.startsWith('_nuxt')) continue
|
||||
if (elementFile.isFile()) {
|
||||
if (element.endsWith('.png')) {
|
||||
const dest = `${output_path}/${element.split('/').slice(0, -1).join('/')}`
|
||||
const res = await imagemin([`${output_path}/${element}`], {
|
||||
destination: dest,
|
||||
plugins: [
|
||||
imageminPngquant({
|
||||
quality: [0.6, 0.8]
|
||||
})
|
||||
]
|
||||
})
|
||||
if (res.length) {
|
||||
console.log(chalk.gray(` compress PNG ${output_path}/${element}`))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
app: {
|
||||
pageTransition: { name: 'page', mode: 'out-in' },
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
"@tresjs/cientos": "^3.9.0",
|
||||
"@tresjs/core": "^4.0.2",
|
||||
"@tresjs/nuxt": "^2.1.2",
|
||||
"imagemin": "^9.0.0",
|
||||
"imagemin-pngquant": "^10.0.0",
|
||||
"marked": "^12.0.2",
|
||||
"nuxt": "^3.11.2",
|
||||
"nuxt-anchorscroll": "^1.0.3",
|
||||
|
|
Loading…
Reference in New Issue