@@ -842,6 +842,38 @@ test.group('Code transformer | addVitePlugin', (group) => {
842
842
` )
843
843
} )
844
844
845
+ test ( 'insert in defineConfig call' , async ( { assert, fs } ) => {
846
+ await fs . create (
847
+ 'vite.config.ts' ,
848
+ `export default defineConfig({
849
+ plugins: [],
850
+ })`
851
+ )
852
+
853
+ const transformer = new CodeTransformer ( fs . baseUrl )
854
+
855
+ await transformer . addVitePlugin ( 'vue({ foo: 32 })' , [
856
+ { identifier : 'vue' , module : 'vue' , isNamed : false } ,
857
+ { identifier : 'foo' , module : 'foo' , isNamed : true } ,
858
+ ] )
859
+
860
+ await transformer . addVitePlugin ( 'vue({ foo: 32 })' , [
861
+ { identifier : 'vue' , module : 'vue' , isNamed : false } ,
862
+ { identifier : 'foo' , module : 'foo' , isNamed : true } ,
863
+ ] )
864
+
865
+ const file = await fs . contents ( 'vite.config.ts' )
866
+ assert . snapshot ( file ) . matchInline ( `
867
+ "import vue from 'vue'
868
+ import { foo } from 'foo'
869
+
870
+ export default defineConfig({
871
+ plugins: [vue({ foo: 32 })],
872
+ })
873
+ "
874
+ ` )
875
+ } )
876
+
845
877
test ( 'throw error when vite.config.ts file is missing' , async ( { fs } ) => {
846
878
const transformer = new CodeTransformer ( fs . baseUrl )
847
879
0 commit comments