test build

This commit is contained in:
Kseninia Mikhaylova 2024-06-25 09:25:50 +03:00
parent 2838ffdb31
commit e765c2feb9
1 changed files with 34 additions and 34 deletions

View File

@ -5,34 +5,34 @@ import imagemin from 'imagemin';
import imageminPngquant from 'imagemin-pngquant'; 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' },
head: { head: {
@ -42,7 +42,7 @@ export default defineNuxtConfig({
}, },
}, },
}, },
ssr: false, ssr: true,
modules: [ modules: [
'@nuxtjs/tailwindcss', '@nuxtjs/tailwindcss',
"@nuxt/image", "@nuxt/image",
@ -62,11 +62,11 @@ export default defineNuxtConfig({
'/index.html': { redirect: '/' }, '/index.html': { redirect: '/' },
'/index.php': { redirect: '/' }, '/index.php': { redirect: '/' },
}, },
nitro: { // nitro: {
prerender: { // prerender: {
crawlLinks: true // crawlLinks: true
}, // },
}, // },
vite: { vite: {
assetsInclude: ['**/*.glb', '**/*.gltf'], assetsInclude: ['**/*.glb', '**/*.gltf'],
build: { build: {