@@ -81,6 +81,10 @@ export async function defineConfig(
8181 const {
8282 autoRenamePlugins = true ,
8383 componentExts = [ ] ,
84+ formatter : formatterOptions = {
85+ css : true ,
86+ html : true ,
87+ } ,
8488 gitignore : enableGitignore = true ,
8589 isInEditor = defaultIsInEditor ,
8690 react : enableReact = false ,
@@ -203,25 +207,27 @@ export async function defineConfig(
203207 sortTsconfig ( ) ,
204208 )
205209 }
210+ if ( formatterOptions ) {
211+ let prettierRules = {
212+ ...DEFAULT_PRETTIER_RULES ,
213+ }
206214
207- let prettierRules = {
208- ...DEFAULT_PRETTIER_RULES ,
209- }
210-
211- if ( options . prettierRules ) {
212- prettierRules = { ...prettierRules , ...options . prettierRules }
213- }
215+ if ( options . prettierRules ) {
216+ prettierRules = { ...prettierRules , ...options . prettierRules }
217+ }
214218
215- if ( usePrettierrc ) {
216- const prettierConfig = await loadPrettierConfig (
217- options . cwd ?? process . cwd ( ) ,
219+ if ( usePrettierrc ) {
220+ const prettierConfig = await loadPrettierConfig (
221+ options . cwd ?? process . cwd ( ) ,
222+ )
223+ Object . assign ( prettierRules , prettierConfig )
224+ }
225+ configs . push (
226+ prettier ( prettierRules ) ,
227+ formatter ( formatterOptions , prettierRules ) ,
218228 )
219- Object . assign ( prettierRules , prettierConfig )
220- }
221- configs . push ( prettier ( options . formatter ? prettierRules : { } ) )
222-
223- if ( options . formatter ) {
224- configs . push ( formatter ( options . formatter , prettierRules ) )
229+ } else {
230+ configs . push ( prettier ( ) )
225231 }
226232
227233 // User can optionally pass a flat config item to the first argument
0 commit comments