Skip to content

Commit

Permalink
Replaced 'as' with a type guard.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dustin Stewart committed Aug 30, 2023
1 parent e323c74 commit 5f1aeb9
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,17 @@ export default defineNuxtModule<Partial<Options>>({

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)
})
)
Expand All @@ -41,13 +45,17 @@ export default defineNuxtModule<Partial<Options>>({
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)
})
)
Expand Down

0 comments on commit 5f1aeb9

Please sign in to comment.