11import { existsSync , promises as fsp } from 'node:fs'
22
3- import { defineNuxtModule , addComponent , addPlugin } from '@nuxt/kit'
3+ import { defineNuxtModule , addComponent , addPlugin , addTemplate } from '@nuxt/kit'
44import { join , resolve } from 'pathe'
55import { readPackageJSON } from 'pkg-types'
66import { defineUnimportPreset } from 'unimport'
@@ -13,6 +13,8 @@ import { setupMeta } from './parts/meta'
1313import { setupPWA } from './parts/pwa'
1414import { setupRouter } from './parts/router'
1515
16+ import type { AnimationBuilder , SpinnerTypes , PlatformConfig } from '@ionic/vue'
17+
1618export interface ModuleOptions {
1719 integrations ?: {
1820 router ?: boolean
@@ -25,6 +27,46 @@ export interface ModuleOptions {
2527 basic ?: boolean
2628 utilities ?: boolean
2729 }
30+ config ?: {
31+ actionSheetEnter ?: AnimationBuilder
32+ actionSheetLeave ?: AnimationBuilder
33+ alertEnter ?: AnimationBuilder
34+ alertLeave ?: AnimationBuilder
35+ animated ?: boolean
36+ backButtonIcon ?: string
37+ backButtonText ?: string
38+ hardwareBackButton ?: boolean
39+ infiniteLoadingSpinner ?: SpinnerTypes
40+ loadingEnter ?: AnimationBuilder
41+ loadingLeave ?: AnimationBuilder
42+ loadingSpinner ?: SpinnerTypes
43+ menuIcon ?: string
44+ menuType ?: string
45+ modalEnter ?: AnimationBuilder
46+ modalLeave ?: AnimationBuilder
47+ mode ?: 'ios' | 'md'
48+ navAnimation ?: AnimationBuilder
49+ pickerEnter ?: AnimationBuilder
50+ pickerLeave ?: AnimationBuilder
51+ platform ?: PlatformConfig
52+ popoverEnter ?: AnimationBuilder
53+ popoverLeave ?: AnimationBuilder
54+ refreshingIcon ?: string
55+ refreshingSpinner ?: SpinnerTypes
56+ sanitizerEnabled ?: boolean
57+ spinner ?: SpinnerTypes
58+ statusTap ?: boolean
59+ swipeBackEnabled ?: boolean
60+ tabButtonLayout ?:
61+ | 'icon-top'
62+ | 'icon-start'
63+ | 'icon-end'
64+ | 'icon-bottom'
65+ | 'icon-hide'
66+ | 'label-hide'
67+ toastEnter ?: AnimationBuilder
68+ toastLeave ?: AnimationBuilder
69+ }
2870}
2971
3072export default defineNuxtModule < ModuleOptions > ( {
@@ -44,12 +86,19 @@ export default defineNuxtModule<ModuleOptions>({
4486 basic : true ,
4587 utilities : false ,
4688 } ,
89+ config : { } ,
4790 } ,
4891 async setup ( options , nuxt ) {
4992 nuxt . options . build . transpile . push ( runtimeDir )
5093 nuxt . options . build . transpile . push ( / @ i o n i c / , / @ s t e n c i l / )
5194
52- // Set up Ionic config
95+ // Inject options for the Ionic Vue plugin as a virtual module
96+ addTemplate ( {
97+ filename : 'ionic/vue-config.mjs' ,
98+ getContents : ( ) => `export default ${ JSON . stringify ( options . config ) } ` ,
99+ } )
100+
101+ // Set up Ionic config file
53102 const ionicConfigPath = join ( nuxt . options . rootDir , 'ionic.config.json' )
54103 if ( ! existsSync ( ionicConfigPath ) ) {
55104 await fsp . writeFile (
0 commit comments