@@ -252,9 +252,8 @@ export class CSSBlocksStylesPostprocessorPlugin extends Filter {
252252
253253 const blocksCssFile = cssBlocksPostprocessFilename ( this . env . config ) ;
254254 let optimizerClasses : string [ ] = [ ] ;
255- const appCss : string [ ] = [ ] ;
256- const foundFiles : string [ ] = [ ] ;
257- const foundClasses : Set < string > = new Set < string > ( ) ;
255+ const appCss : { relPath : string ; content : string } [ ] = [ ] ;
256+ const foundClasses : { relPath : string ; className : string ; loc ?: postcss . NodeSource } [ ] = [ ] ;
258257 const errorLog : string [ ] = [ ] ;
259258
260259 // Are there any changes to make? If not, bail out early.
@@ -291,24 +290,30 @@ export class CSSBlocksStylesPostprocessorPlugin extends Filter {
291290 walkEntries . forEach ( entry => {
292291 if ( entry . relativePath === blocksCssFile ) return ;
293292 try {
294- appCss . push ( this . input . readFileSync ( entry . relativePath ) . toString ( "utf8" ) ) ;
295- foundFiles . push ( entry . relativePath ) ;
293+ appCss . push ( {
294+ relPath : entry . relativePath ,
295+ content : this . input . readFileSync ( entry . relativePath ) . toString ( "utf8" ) ,
296+ } ) ;
296297 } catch ( e ) {
297298 // broccoli-concat will complain about this later. let's move on.
298299 }
299300 } ) ;
300301 debug ( "Done looking up app CSS." ) ;
301302
302303 // Now, read in each of these sources and note all classes found.
303- appCss . forEach ( content => {
304+ appCss . forEach ( css => {
304305 try {
305- const parsed = postcss . parse ( content ) ;
306+ const parsed = postcss . parse ( css . content ) ;
306307 parsed . walkRules ( rule => {
307308 const selectors = parseSelector ( rule . selector ) ;
308309 selectors . forEach ( sel => {
309310 sel . eachSelectorNode ( node => {
310311 if ( node . type === "class" ) {
311- foundClasses . add ( node . value ) ;
312+ foundClasses . push ( {
313+ relPath : css . relPath ,
314+ className : node . value ,
315+ loc : rule . source ,
316+ } ) ;
312317 }
313318 } ) ;
314319 } ) ;
@@ -322,16 +327,12 @@ export class CSSBlocksStylesPostprocessorPlugin extends Filter {
322327 debug ( "Done finding app classes." ) ;
323328
324329 // Find collisions between the app styles and optimizer styles.
325- const collisions = optimizerClasses . filter ( val => foundClasses . has ( val ) ) ;
330+ const collisions = foundClasses . filter ( val => optimizerClasses . includes ( val . className ) ) ;
326331 debug ( "Done identifying collisions." ) ;
327332
328333 // Build a logfile for the output tree, for debugging.
329- let logfile = "COLLISIONS:\n" ;
330- collisions . forEach ( cssClass => { logfile += `${ cssClass } \n` ; } ) ;
331- logfile += "\nFOUND APP CLASSES:\n" ;
332- foundClasses . forEach ( cssClass => { logfile += `${ cssClass } \n` ; } ) ;
333- logfile += "\nFOUND FILES:\n" ;
334- foundFiles . forEach ( file => { logfile += `${ file } \n` ; } ) ;
334+ let logfile = "FOUND APP CLASSES:\n" ;
335+ foundClasses . forEach ( curr => { logfile += `${ curr . className } (in ${ curr . relPath } - ${ curr . loc ?. start ?. line } :${ curr . loc ?. start ?. column } )\n` ; } ) ;
335336 logfile += "\nERRORS:\n" ;
336337 errorLog . forEach ( err => { logfile += `${ err } \n` ; } ) ;
337338 this . output . writeFileSync ( "assets/app-classes.log" , logfile ) ;
@@ -343,7 +344,7 @@ export class CSSBlocksStylesPostprocessorPlugin extends Filter {
343344 "To resolve this conflict, you should add any short class names in non-block CSS (~5 characters or less) to the list of disallowed classes in your build configuration.\n" +
344345 "(You can do this by setting css-blocks.appClasses to an array of disallowed classes in ember-cli-build.js.)\n\n" +
345346 "Conflicting classes:\n" +
346- collisions . reduce ( ( prev , curr ) => prev += `${ curr } \n` , "" ) ,
347+ collisions . reduce ( ( prev , curr ) => prev += `${ curr . className } (in ${ curr . relPath } - ${ curr . loc ?. start ?. line } : ${ curr . loc ?. start ?. column } ) \n` , "" ) ,
347348 ) ;
348349 }
349350 }
0 commit comments