@@ -7,6 +7,7 @@ exports.CssWatcher = void 0;
77const fs_1 = __importDefault ( require ( "fs" ) ) ;
88const chokidar_1 = __importDefault ( require ( "chokidar" ) ) ;
99const css_extractor_1 = require ( "./css-extractor" ) ;
10+ const micromatch_1 = __importDefault ( require ( "micromatch" ) ) ;
1011class CssWatcher {
1112 constructor ( patterns = [ '**/*.css' ] , ignore = [ '**/node_modules/**' , '**/dist/**' , '**/out/**' , '**/build/**' ] ) {
1213 this . state = {
@@ -15,21 +16,20 @@ class CssWatcher {
1516 } ;
1617 this . watcher = null ;
1718 this . patterns = patterns ;
18- this . ignorePatterns = ignore ;
19+ // Ignore hidden files by default
20+ this . ignorePatterns = [ '**/.*' , ...ignore ] ;
1921 this . setupWatcher ( ) ;
2022 }
2123 setupWatcher ( ) {
22- // Initial scan and watch setup
23- const watchPatterns = this . patterns . map ( ( pattern ) => {
24- // Convert Windows-style paths if necessary
25- return pattern . replace ( / \\ / g, '/' ) ;
26- } ) ;
2724 // Set up chokidar with appropriate options
28- this . watcher = chokidar_1 . default . watch ( watchPatterns , {
25+ const cwd = process . cwd ( ) ;
26+ this . watcher = chokidar_1 . default . watch ( cwd , {
2927 persistent : true ,
3028 ignoreInitial : false , // This ensures we get the initial scan
31- ignored : [ ...this . ignorePatterns , / ( ^ | [ / \\ ] ) \. ./ ] , // Ignore dotfiles and user-specified patterns
32- cwd : '.' , // Use current working directory as base
29+ ignored : ( path , stats ) => {
30+ return ( micromatch_1 . default . isMatch ( path , this . ignorePatterns ) ||
31+ ! ! ( ( stats === null || stats === void 0 ? void 0 : stats . isFile ( ) ) && ! micromatch_1 . default . isMatch ( path , this . patterns ) ) ) ;
32+ } ,
3333 followSymlinks : true ,
3434 awaitWriteFinish : {
3535 stabilityThreshold : 200 ,
@@ -39,6 +39,7 @@ class CssWatcher {
3939 // Setup event handlers
4040 this . watcher
4141 . on ( 'add' , ( filePath ) => {
42+ console . log ( '!!' , filePath ) ;
4243 this . updateClassesForFile ( filePath ) ;
4344 } )
4445 . on ( 'change' , ( filePath ) => {
0 commit comments