function addWrapperWithGlobals(name, config, defsObj, callback) {
  config.module.rules.push({
    test: new RegExp(`/${name}/.*?\\.js$`.replace(/\//g, /[/\\]/.source)),
    use: [{
      loader: './scripts/fake-dep-loader.js',
      options: { files: entryGlobals[name].map(entryPathToFilename) },
    }],
  });
  const defsRe = new RegExp(`\\b(${
    Object.keys(defsObj)
    .join('|')
    .replace(/\./g, '\\.')
  })\\b`, 'g');
  const reader = () => (
    entryGlobals[name]
    .map(path => readGlobalsFile(path))
    .join('\n')
    .replace(defsRe, s => defsObj[s])
  );
  const { header, footer, test } = callback(reader);
  config.plugins.push(
    new webpack.BannerPlugin({ test, raw: true, banner: header }),
    new webpack.BannerPlugin({ test, raw: true, banner: footer, footer: true })
  );
}
Adds a watcher for files in entryGlobals to properly recompile the project on changes.