@@ -252,9 +252,8 @@ export class CSSBlocksStylesPostprocessorPlugin extends Filter {
252
252
253
253
const blocksCssFile = cssBlocksPostprocessFilename ( this . env . config ) ;
254
254
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 } [ ] = [ ] ;
258
257
const errorLog : string [ ] = [ ] ;
259
258
260
259
// Are there any changes to make? If not, bail out early.
@@ -291,24 +290,30 @@ export class CSSBlocksStylesPostprocessorPlugin extends Filter {
291
290
walkEntries . forEach ( entry => {
292
291
if ( entry . relativePath === blocksCssFile ) return ;
293
292
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
+ } ) ;
296
297
} catch ( e ) {
297
298
// broccoli-concat will complain about this later. let's move on.
298
299
}
299
300
} ) ;
300
301
debug ( "Done looking up app CSS." ) ;
301
302
302
303
// Now, read in each of these sources and note all classes found.
303
- appCss . forEach ( content => {
304
+ appCss . forEach ( css => {
304
305
try {
305
- const parsed = postcss . parse ( content ) ;
306
+ const parsed = postcss . parse ( css . content ) ;
306
307
parsed . walkRules ( rule => {
307
308
const selectors = parseSelector ( rule . selector ) ;
308
309
selectors . forEach ( sel => {
309
310
sel . eachSelectorNode ( node => {
310
311
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
+ } ) ;
312
317
}
313
318
} ) ;
314
319
} ) ;
@@ -322,16 +327,12 @@ export class CSSBlocksStylesPostprocessorPlugin extends Filter {
322
327
debug ( "Done finding app classes." ) ;
323
328
324
329
// 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 ) ) ;
326
331
debug ( "Done identifying collisions." ) ;
327
332
328
333
// 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` ; } ) ;
335
336
logfile += "\nERRORS:\n" ;
336
337
errorLog . forEach ( err => { logfile += `${ err } \n` ; } ) ;
337
338
this . output . writeFileSync ( "assets/app-classes.log" , logfile ) ;
@@ -343,7 +344,7 @@ export class CSSBlocksStylesPostprocessorPlugin extends Filter {
343
344
"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" +
344
345
"(You can do this by setting css-blocks.appClasses to an array of disallowed classes in ember-cli-build.js.)\n\n" +
345
346
"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` , "" ) ,
347
348
) ;
348
349
}
349
350
}
0 commit comments