Skip to content

Commit

Permalink
fix: nuxt 3.0.0 stable support (#250)
Browse files Browse the repository at this point in the history
Co-authored-by: Joaqu铆n S谩nchez <joaquin.sanchez@fi2net.es>
fixes #249
  • Loading branch information
chriscab83 committed Nov 22, 2022
1 parent 6868326 commit a7e7c03
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 0 additions & 2 deletions examples/nuxt3/nuxt.config.ts
@@ -1,5 +1,3 @@
import { defineNuxtConfig } from 'nuxt'

// https://v3.nuxtjs.org/api/configuration/nuxt.config
export default defineNuxtConfig({
modules: [
Expand Down
5 changes: 3 additions & 2 deletions examples/nuxt3/package.json
Expand Up @@ -7,8 +7,9 @@
"preview": "nuxt preview"
},
"devDependencies": {
"@iconify/json": "^2.1.131",
"nuxt": "3.0.0-rc.12",
"@iconify-json/logos": "^1.1.18",
"@iconify-json/mdi": "^1.1.34",
"nuxt": "^3.0.0",
"unplugin-icons": "link:../.."
}
}
10 changes: 6 additions & 4 deletions src/nuxt.ts
@@ -1,20 +1,22 @@
import type { Options } from './types'
import unplugin from '.'

export default function (this: any, options: Options = {}) {
if (this.nuxt?._version?.startsWith('3.'))
export default function (this: any, options: Options = {}, nuxt: any) {
const nuxtApp = this?.nuxt || nuxt

if (nuxtApp?._version?.startsWith('3.'))
options.compiler = 'vue3'

// install webpack plugin
this.nuxt.hook('webpack:config', (configs: any[]) => {
nuxtApp.hook('webpack:config', (configs: any[]) => {
configs.forEach((config) => {
config.plugins = config.plugins || []
config.plugins.unshift(unplugin.webpack(options))
})
})

// install vite plugin
this.nuxt.hook('vite:extend', async (vite: any) => {
nuxtApp.hook('vite:extend', async (vite: any) => {
vite.config.plugins = vite.config.plugins || []
vite.config.plugins.push(unplugin.vite(options))
})
Expand Down

0 comments on commit a7e7c03

Please sign in to comment.