@@ -34,7 +34,8 @@ export const stylePlugin: EleventyPlugin<StylePluginConfig, EleventyGlobalData>
3434 } ) ;
3535
3636 if ( ! cssMinify ) {
37- content = await prettifyCss ( content ) ;
37+ const prettierOptions = pluginConfig . prettier ?? false ;
38+ content = await prettifyCss ( content , inputPath , prettierOptions ) ;
3839 }
3940
4041 return `${ pluginConfig . banner } \n${ content } ` ;
@@ -57,7 +58,8 @@ export const stylePlugin: EleventyPlugin<StylePluginConfig, EleventyGlobalData>
5758 } ) ;
5859
5960 if ( ! cssMinify ) {
60- content = await prettifyCss ( content ) ;
61+ const prettierOptions = pluginConfig . prettier ?? false ;
62+ content = await prettifyCss ( content , inputPath , prettierOptions ) ;
6163 }
6264
6365 return `${ pluginConfig . banner } \n${ content } ` ;
@@ -76,12 +78,22 @@ export const stylePlugin: EleventyPlugin<StylePluginConfig, EleventyGlobalData>
7678/**
7779 *
7880 * @param content
81+ * @param inputPath
82+ * @param prettierOptions
7983 */
80- async function prettifyCss ( content : string ) {
84+ async function prettifyCss (
85+ content : string ,
86+ inputPath : string ,
87+ prettierOptions : PrettierOptions | boolean ,
88+ ) {
8189 const prettier = await import ( 'prettier' ) ;
90+ const options = typeof prettierOptions === 'object' ? prettierOptions : { } ;
91+ const config = await prettier . resolveConfig ( inputPath ) ;
8292 return await prettier . format ( content , {
8393 parser : 'css' ,
8494 tabWidth : 2 ,
8595 useTabs : false ,
96+ ...options ,
97+ ...config ,
8698 } ) ;
8799}
0 commit comments