From 91e6897a0394cbb4dd424f30cff63abbd15198a5 Mon Sep 17 00:00:00 2001 From: Thorn Walli Date: Wed, 13 Sep 2023 15:23:30 +0200 Subject: [PATCH] fix(module): fix preloads --- src/module.mjs | 2 +- src/utils/preload.mjs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/module.mjs b/src/module.mjs index 2c14d53d7e..2fdc2392b8 100644 --- a/src/module.mjs +++ b/src/module.mjs @@ -80,7 +80,7 @@ export default defineNuxtModule({ } if (moduleOptions.optimizePreloads) { - optimizePreloads(nuxt); + optimizePreloads(moduleOptions, nuxt); } else { logger.warn( 'Preload optimization is disabled by module option `optimizePreloads`.' diff --git a/src/utils/preload.mjs b/src/utils/preload.mjs index 4244e5dfc7..b159c660fc 100644 --- a/src/utils/preload.mjs +++ b/src/utils/preload.mjs @@ -6,7 +6,7 @@ import { render } from 'dom-serializer'; import { isViteBuild, logger } from '../utils.mjs'; // eslint-disable-next-line sonarjs/cognitive-complexity -export function optimizePreloads(nuxt) { +export function optimizePreloads(moduleOptions, nuxt) { if (isViteBuild(nuxt)) { nuxt.options.vite.build.manifest = false; if (nuxt.options.speedkit.disableNuxtCritters) { @@ -48,7 +48,7 @@ export function optimizePreloads(nuxt) { const filepath = join(publicDir, basename($el.attr('href'))); const fileContent = await fsPromises.readFile(filepath, 'utf-8'); - if (nuxt.options.speedkit.disableNuxtCritters) { + if (moduleOptions.disableNuxtCritters) { const css = fileContent.replace(/url\(.\//g, `url(${dir}/`); $el.remove(); logger.info(