test imagemin

This commit is contained in:
Kseninia Mikhaylova 2024-06-21 15:58:41 +03:00
parent 6b2d8b4400
commit 2c24b17aef
3 changed files with 29 additions and 26 deletions

View File

@ -2,6 +2,7 @@
FROM debian:bookworm-slim FROM debian:bookworm-slim
RUN apt update RUN apt update
RUN apt -y install nodejs npm RUN apt -y install nodejs npm
RUN apt -y install libpng-dev libimagequant-dev
RUN mkdir -p /src RUN mkdir -p /src
COPY package.json src/package.json COPY package.json src/package.json

View File

@ -6,32 +6,32 @@ import imageminPngquant from 'imagemin-pngquant';
export default defineNuxtConfig({ export default defineNuxtConfig({
hooks: { hooks: {
// 'nitro:build:public-assets': async (nitro) => { 'nitro:build:public-assets': async (nitro) => {
// console.log(`😈 custom hook imagemin in ${nitro.options.output.publicDir}`) console.log(`😈 custom hook imagemin in ${nitro.options.output.publicDir}`)
// const output_path = nitro.options.output.publicDir const output_path = nitro.options.output.publicDir
// const filelist = await fs.readdir(output_path, { recursive: true }); const filelist = await fs.readdir(output_path, { recursive: true });
// for (let index = 0; index < filelist.length; index++) { for (let index = 0; index < filelist.length; index++) {
// const element = filelist[index]; const element = filelist[index];
// const elementFile = await fs.lstat(`${output_path}/${element}`) const elementFile = await fs.lstat(`${output_path}/${element}`)
// if (element.startsWith('_nuxt')) continue if (element.startsWith('_nuxt')) continue
// if (elementFile.isFile()) { if (elementFile.isFile()) {
// if (element.endsWith('.png')) { if (element.endsWith('.png')) {
// const dest = `${output_path}/${element.split('/').slice(0, -1).join('/')}` const dest = `${output_path}/${element.split('/').slice(0, -1).join('/')}`
// const res = await imagemin([`${output_path}/${element}`], { const res = await imagemin([`${output_path}/${element}`], {
// destination: dest, destination: dest,
// plugins: [ plugins: [
// imageminPngquant({ imageminPngquant({
// quality: [0.6, 0.8] quality: [0.6, 0.8]
// }) })
// ] ]
// }) })
// if (res.length) { if (res.length) {
// console.log(chalk.gray(` compress PNG ${output_path}/${element}`)) console.log(chalk.gray(` compress PNG ${output_path}/${element}`))
// } }
// } }
// } }
// } }
// } }
}, },
app: { app: {
pageTransition: { name: 'page', mode: 'out-in' }, pageTransition: { name: 'page', mode: 'out-in' },

View File

@ -18,6 +18,8 @@
"@tresjs/cientos": "^3.9.0", "@tresjs/cientos": "^3.9.0",
"@tresjs/core": "^4.0.2", "@tresjs/core": "^4.0.2",
"@tresjs/nuxt": "^2.1.2", "@tresjs/nuxt": "^2.1.2",
"imagemin": "^9.0.0",
"imagemin-pngquant": "^10.0.0",
"marked": "^12.0.2", "marked": "^12.0.2",
"nuxt": "^3.11.2", "nuxt": "^3.11.2",
"nuxt-anchorscroll": "^1.0.3", "nuxt-anchorscroll": "^1.0.3",