diff --git a/nuxt.config.ts b/nuxt.config.ts index bdf49ec..96de4e5 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -5,34 +5,34 @@ import imagemin from 'imagemin'; 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}`)) - // } - // } - // } - // } - // } - // }, + 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}`)) + } + } + } + } + } + }, app: { pageTransition: { name: 'page', mode: 'out-in' }, head: { @@ -62,11 +62,11 @@ export default defineNuxtConfig({ '/index.html': { redirect: '/' }, '/index.php': { redirect: '/' }, }, - nitro: { - prerender: { - crawlLinks: true - }, - }, + // nitro: { + // prerender: { + // crawlLinks: true + // }, + // }, vite: { assetsInclude: ['**/*.glb', '**/*.gltf'], build: {