Skip to content

Commit

Permalink
feat: supports the webpack plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangmo8 committed Apr 15, 2023
1 parent e22c036 commit 10be091
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default defineNuxtModule<ModuleOptions>({
configKey: moduleName
},
defaults,
setup (_options: ModuleOptions, nuxt) {
setup(_options: ModuleOptions, nuxt) {
const _configs = _options
resolveOptions()

Expand All @@ -28,9 +28,24 @@ export default defineNuxtModule<ModuleOptions>({
sourcemap: nuxt.options.sourcemap[mode],
transformStyles: name => resolveStyles(_configs, name),
transformDirectives: name => resolveDirectives(_configs, name)

})
)
})

nuxt.hook('webpack:config', (configs) => {
configs.forEach((config) => {
const mode = config.name === 'client' ? 'client' : 'server'

config.plugins.push(
transformPlugin.webpack({
include: _configs.include,
exclude: _configs.exclude,
sourcemap: nuxt.options.sourcemap[mode],
transformStyles: name => resolveStyles(_configs, name),
transformDirectives: name => resolveDirectives(_configs, name)
})
)
})
})
}
})

0 comments on commit 10be091

Please sign in to comment.