UNPKG

693 BJavaScriptView Raw
1'use strict';
2
3var fs = require('fs');
4var path = require('path');
5var script = fs.readFileSync(path.resolve(__dirname, './globScript.js'));
6
7function injectScript() {}
8
9injectScript.prototype.apply = function (compiler) {
10 compiler.plugin('emit', function (compilation, callback) {
11 compilation.chunks.forEach(function (chunk) {
12 chunk.files.forEach(function (filename) {
13 if (filename === 'vendor.js') {
14 compilation.assets[filename].children.forEach(function (child) {
15 if (child._value) {
16 child._value = script + child._value;
17 }
18 });
19 }
20 });
21 });
22 callback();
23 });
24};
25
26module.exports = injectScript;
\No newline at end of file