packages/strapi/lib/commands/develop.js
/**
 * Init file watching to auto restart strapi app
 * @param {Object} options - Options object
 * @param {string} options.dir - This is the path where the app is located, the watcher will watch the files under this folder
 * @param {Strapi} options.strapi - Strapi instance
 * @param {array} options.watchIgnoreFiles - Array of custom file paths that should not be watched
 */
Init file watching to auto restart strapi app
@param {Object} options - Options object
@param {string} options.dir - This is the path where the app is located, the watcher will watch the files under this folder
@param {Strapi} options.strapi - Strapi instance
@param {array} options.watchIgnoreFiles - Array of custom file paths that should not be watched
Init file watching to auto restart strapi app @param { Object } options - Options object @param { string } options . dir - This is the path where the app is located the watcher will watch the files under this folder @param { Strapi } options . strapi - Strapi instance @param { array } options . watchIgnoreFiles - Array of custom file paths that should not be watched
function watchFileChanges({ dir, strapiInstance, watchIgnoreFiles }) {
  const restart = () => {
    if (
      strapiInstance.reload.isWatching &&
      !strapiInstance.reload.isReloading
    ) {
      strapiInstance.reload.isReloading = true;
      strapiInstance.reload();
    }
  };
  const watcher = chokidar.watch(dir, {
    ignoreInitial: true,
    ignored: [
      /(^|[/\\])\../, 
      /tmp/,
      '**/admin',
      '**/admin/**',
      'extensions/**/admin',
      'extensions/**/admin/**',
      '**/documentation',
      '**/documentation/**',
      '**/node_modules',
      '**/node_modules/**',
      '**/plugins.json',
      '**/index.html',
      '**/public',
      '**/public/**',
      '**/cypress',
      '**/cypress/**',
      '**/*.db*',
      '**/exports/**',
      ...watchIgnoreFiles,
    ],
  });
  watcher
    .on('add', path => {
      strapiInstance.log.info(`File created: ${path}`);
      restart();
    })
    .on('change', path => {
      strapiInstance.log.info(`File changed: ${path}`);
      restart();
    })
    .on('unlink', path => {
      strapiInstance.log.info(`File deleted: ${path}`);
      restart();
    });
}
function watchFileChanges ( { dir , strapiInstance , watchIgnoreFiles } ) { const restart = ( ) => { if ( strapiInstance . reload . isWatching && ! strapiInstance . reload . isReloading ) { strapiInstance . reload . isReloading = true ; strapiInstance . reload ( ) ; } } ; const watcher = chokidar . watch ( dir , { ignoreInitial : true , ignored : [ / (^|[/\\])\.. / , / tmp / , '**/admin' , '**/admin/**' , 'extensions/**/admin' , 'extensions/**/admin/**' , '**/documentation' , '**/documentation/**' , '**/node_modules' , '**/node_modules/**' , '**/plugins.json' , '**/index.html' , '**/public' , '**/public/**' , '**/cypress' , '**/cypress/**' , '**/*.db*' , '**/exports/**' , ... watchIgnoreFiles , ] , } ) ; watcher . on ( 'add' , path => { strapiInstance . log . info ( ` ${ path } ` ) ; restart ( ) ; } ) . on ( 'change' , path => { strapiInstance . log . info ( ` ${ path } ` ) ; restart ( ) ; } ) . on ( 'unlink' , path => { strapiInstance . log . info ( ` ${ path } ` ) ; restart ( ) ; } ) ; }
Init file watching to auto restart strapi app
 @param {Object} options - Options object
 @param {string} options.dir - This is the path where the app is located, the watcher will watch the files under this folder
 @param {Strapi} options.strapi - Strapi instance
 @param {array} options.watchIgnoreFiles - Array of custom file paths that should not be watched
Init file watching to auto restart strapi app @param { Object } options - Options object @param { string } options . dir - This is the path where the app is located the watcher will watch the files under this folder @param { Strapi } options . strapi - Strapi instance @param { array } options . watchIgnoreFiles - Array of custom file paths that should not be watched
// dot files