diff --git a/src/module.ts b/src/module.ts index 317d9ef..af71143 100644 --- a/src/module.ts +++ b/src/module.ts @@ -26,13 +26,17 @@ export default defineNuxtModule>({ nuxt.hook('vite:extendConfig', (config, { isClient }) => { const mode = isClient ? 'client' : 'server' + const sourcemapValue = nuxt.options.sourcemap[mode] + if (typeof sourcemapValue !== 'boolean') { + throw new TypeError(`Expected a boolean for sourcemap[${mode}], but received ${typeof sourcemapValue}.`) + } config.plugins = config.plugins || [] config.plugins.push( transformPlugin.vite({ include: options.include, exclude: options.exclude, - sourcemap: nuxt.options.sourcemap[mode] as boolean, + sourcemap: sourcemapValue, transformStyles: name => resolveStyles(options, name) }) ) @@ -41,13 +45,17 @@ export default defineNuxtModule>({ nuxt.hook('webpack:config', (configs) => { configs.forEach((config) => { const mode = config.name === 'client' ? 'client' : 'server' + const sourcemapValue = nuxt.options.sourcemap[mode] + if (typeof sourcemapValue !== 'boolean') { + throw new TypeError(`Expected a boolean for sourcemap[${mode}], but received ${typeof sourcemapValue}.`) + } config.plugins = config.plugins || [] config.plugins.push( transformPlugin.webpack({ include: options.include, exclude: options.exclude, - sourcemap: nuxt.options.sourcemap[mode] as boolean, + sourcemap: sourcemapValue, transformStyles: name => resolveStyles(options, name) }) )