Skip to content

Commit

Permalink
feat(nuxt): support nuxt options field
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Sep 1, 2021
1 parent 20fe442 commit f5b7a29
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 13 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export default {
'@nuxtjs/composition-api/module',
'unplugin-vue2-script-setup/nuxt',
],
scriptSetup: { /* options */ },
}
```

Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"@antfu/utils": "^0.3.0",
"@rollup/pluginutils": "^4.1.1",
"@types/jest": "^27.0.1",
"@types/node": "^16.7.8",
"@types/node": "^16.7.10",
"@vue/composition-api": "^1.1.4",
"@vue/runtime-dom": "^3.2.6",
"bumpp": "^6.0.6",
Expand All @@ -83,7 +83,7 @@
"ts-jest": "^27.0.5",
"tsup": "^4.14.0",
"typescript": "^4.4.2",
"vite": "^2.5.1"
"vite": "^2.5.3"
},
"dependencies": {
"@babel/core": "^7.15.0",
Expand All @@ -93,8 +93,9 @@
"@babel/types": "^7.15.0",
"@vue/ref-transform": "^3.2.6",
"@vue/shared": "^3.2.6",
"defu": "^5.0.0",
"htmlparser2": "^6.1.0",
"magic-string": "^0.25.7",
"unplugin": "^0.2.6"
"unplugin": "^0.2.7"
}
}
37 changes: 28 additions & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion src/nuxt.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import defu from 'defu'
import { PluginOptions } from './types'
import unplugin from '.'

export default function(this: any, options?: PluginOptions) {
export default function(this: any, inlineOptions: PluginOptions = {}) {
const options = defu(inlineOptions, this.nuxt.options.scriptSetup)

// install webpack plugin
this.extendBuild((config: any) => {
config.plugins = config.plugins || []
Expand Down

0 comments on commit f5b7a29

Please sign in to comment.