From 412e869bae43f24aa9fdf92fab94cabe3257e3b2 Mon Sep 17 00:00:00 2001 From: Thorn Walli Date: Wed, 24 Apr 2024 20:42:27 +0200 Subject: [PATCH 1/3] fix(module): integrate default targetFormats in defaults --- src/module.js | 3 --- src/utils.js | 2 -- src/utils/options.js | 2 +- 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/module.js b/src/module.js index 4df716e18d..6fd11f2924 100644 --- a/src/module.js +++ b/src/module.js @@ -10,7 +10,6 @@ import { import { getCrossorigin } from './runtime/utils'; import FontConfig from './runtime/classes/FontConfig'; import { - DEFAULT_TARGET_FORMATS, MODULE_NAME, addNuxtFontaine, addNuxtImage, @@ -176,8 +175,6 @@ async function addModules(nuxt, moduleOptions) { await addNuxtFontaine(nuxt); } if (!moduleOptions.disableNuxtImage) { - moduleOptions.targetFormats = - moduleOptions.targetFormats || DEFAULT_TARGET_FORMATS; await addNuxtImage(nuxt); } } diff --git a/src/utils.js b/src/utils.js index de1af078cd..a29959ebf4 100644 --- a/src/utils.js +++ b/src/utils.js @@ -1,8 +1,6 @@ import { defu } from 'defu'; import { installModule, useLogger } from '@nuxt/kit'; -export const DEFAULT_TARGET_FORMATS = ['webp', 'avif', 'jpg|jpeg|png|gif']; - export const MODULE_NAME = 'nuxt-booster'; export const logger = useLogger(MODULE_NAME); diff --git a/src/utils/options.js b/src/utils/options.js index 736a07867d..9a502a20e3 100644 --- a/src/utils/options.js +++ b/src/utils/options.js @@ -26,7 +26,7 @@ export function getDefaultOptions() { fonts: [], - targetFormats: undefined, + targetFormats: ['webp', 'avif', 'jpg|jpeg|png|gif'], densities: 'x1 x2', /** From 6b4b2a9a462ba76a5b076adeb898ee4b22dac053 Mon Sep 17 00:00:00 2001 From: Thorn Walli Date: Wed, 24 Apr 2024 20:52:37 +0200 Subject: [PATCH 2/3] fix(module): remove types from defaults --- src/module.js | 6 +++++- src/utils/options.js | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/module.js b/src/module.js index 6fd11f2924..c19f74fa76 100644 --- a/src/module.js +++ b/src/module.js @@ -80,7 +80,7 @@ export default defineNuxtModule({ 'Preload optimization is disabled by module option `optimizePreloads`.' ); } - + console.log(moduleOptions); await addBuildTemplates(nuxt, moduleOptions); addImports( @@ -123,6 +123,7 @@ async function addBuildTemplates(nuxt, options) { }); ['client', 'server'].forEach(mode => { + console.log('targetFormats', options.targetFormats); addPluginTemplate({ getContents: () => { return pluginTemplate({ @@ -175,6 +176,9 @@ async function addModules(nuxt, moduleOptions) { await addNuxtFontaine(nuxt); } if (!moduleOptions.disableNuxtImage) { + if (!moduleOptions.targetFormats?.length) { + moduleOptions.targetFormats = ['webp', 'avif', 'jpg|jpeg|png|gif']; + } await addNuxtImage(nuxt); } } diff --git a/src/utils/options.js b/src/utils/options.js index 9a502a20e3..9b3379381c 100644 --- a/src/utils/options.js +++ b/src/utils/options.js @@ -26,7 +26,7 @@ export function getDefaultOptions() { fonts: [], - targetFormats: ['webp', 'avif', 'jpg|jpeg|png|gif'], + targetFormats: [], densities: 'x1 x2', /** From b8429c0a225f7111b6f8d71167b656df1627553e Mon Sep 17 00:00:00 2001 From: Thorn Walli Date: Wed, 24 Apr 2024 20:54:16 +0200 Subject: [PATCH 3/3] fix(module): remove logs --- src/module.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/module.js b/src/module.js index c19f74fa76..3ad4ccaa87 100644 --- a/src/module.js +++ b/src/module.js @@ -80,7 +80,7 @@ export default defineNuxtModule({ 'Preload optimization is disabled by module option `optimizePreloads`.' ); } - console.log(moduleOptions); + await addBuildTemplates(nuxt, moduleOptions); addImports( @@ -123,7 +123,6 @@ async function addBuildTemplates(nuxt, options) { }); ['client', 'server'].forEach(mode => { - console.log('targetFormats', options.targetFormats); addPluginTemplate({ getContents: () => { return pluginTemplate({