File tree Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -33,10 +33,32 @@ BrowserSyncPlugin.prototype.apply = function (compiler) {
3333 } ) ;
3434
3535 compiler . plugin ( 'done' , function ( stats ) {
36+
37+ // assets contains all the compiled assets
38+ var assets = _ . keys ( stats . compilation . assets ) ,
39+ isCSS = _ ( assets )
40+ // organize the assets for cleaner use
41+ . map ( function ( asset ) {
42+ return {
43+ name : asset ,
44+ emitted : stats . compilation . assets [ asset ] . emitted
45+ }
46+ } )
47+ // remove asset files that have not been emitted
48+ . filter ( function ( asset ) { return asset . emitted } )
49+ // true if all assets contain .css, false for anything else (.js, .img, etc)
50+ . every ( function ( asset ) {
51+ return asset . name . match ( '.css' ) !== null ;
52+ } ) ;
53+
3654 if ( self . isWebpackWatching ) {
3755 if ( self . isBrowserSyncRunning ) {
3856 if ( self . options . reload ) {
39- self . browserSync . reload ( ) ;
57+ if ( isCSS )
58+ // inject css if all compiled assets are css
59+ self . browserSync . reload ( '*.css' ) ;
60+ else
61+ self . browserSync . reload ( ) ;
4062 }
4163 } else {
4264 if ( _ . isFunction ( self . options . callback ) ) {
You can’t perform that action at this time.
0 commit comments