MCPcopy Create free account
hub / github.com/violentmonkey/violentmonkey / addWrapperWithGlobals

Function addWrapperWithGlobals

scripts/webpack-util.js:49–73  ·  view source on GitHub ↗

* Adds a watcher for files in entryGlobals to properly recompile the project on changes.

(name, config, defsObj, callback)

Source from the content-addressed store, hash-verified

47 * Adds a watcher for files in entryGlobals to properly recompile the project on changes.
48 */
49function addWrapperWithGlobals(name, config, defsObj, callback) {
50 config.module.rules.push({
51 test: new RegExp(`/${name}/.*?\\.js$`.replace(/\//g, /[/\\]/.source)),
52 use: [{
53 loader: './scripts/fake-dep-loader.js',
54 options: { files: entryGlobals[name].map(entryPathToFilename) },
55 }],
56 });
57 const defsRe = new RegExp(`\\b(${
58 Object.keys(defsObj)
59 .join('|')
60 .replace(/\./g, '\\.')
61 })\\b`, 'g');
62 const reader = () => (
63 entryGlobals[name]
64 .map(path => readGlobalsFile(path))
65 .join('\n')
66 .replace(defsRe, s => defsObj[s])
67 );
68 const { header, footer, test } = callback(reader);
69 config.plugins.push(
70 new webpack.BannerPlugin({ test, raw: true, banner: header }),
71 new webpack.BannerPlugin({ test, raw: true, banner: footer, footer: true })
72 );
73}
74
75function getCodeMirrorThemes() {
76 const name = 'neo.css';

Callers 1

webpack.conf.jsFile · 0.85

Calls 1

mapMethod · 0.80

Tested by

no test coverage detected