UNPKG

@gdjiami/cli

Version:

CLI for build front end project.

28 lines (27 loc) 1.07 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var NAME = 'HtmlInjectedEnvrioments'; var HtmlInjectedEnvrioments = /** @class */ (function () { function HtmlInjectedEnvrioments(env, namespace) { this.env = env; this.namespace = namespace; } HtmlInjectedEnvrioments.prototype.apply = function (compiler) { var _this = this; compiler.hooks.compilation.tap(NAME, function (compilation) { require('html-webpack-plugin') .getHooks(compilation) .alterAssetTagGroups.tapAsync(NAME, function (data, cb) { // inject enviroments data.headTags.push({ tagName: 'script', attributes: {}, innerHTML: "window." + _this.namespace + " = " + JSON.stringify(_this.env, null, 2), }); cb(null, data); }); }); }; return HtmlInjectedEnvrioments; }()); exports.default = HtmlInjectedEnvrioments;