UNPKG

piral-instance-webpack-plugin

Version:

Webpack plugin for generating a valid Piral instance bundle.

31 lines 1.27 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PiralInstanceWebpackPlugin = void 0; const webpack_1 = require("webpack"); const helpers_1 = require("./helpers"); const pluginName = 'PiralInstanceWebpackPlugin'; class PiralInstanceWebpackPlugin { constructor(options) { this.options = options; } apply(compiler) { const { name, version, debug, emulator, externals } = this.options; const environment = process.env.NODE_ENV || 'development'; const variables = { ...(0, helpers_1.getVariables)(name, version, externals, environment), ...this.options.variables, }; if (debug) { variables.DEBUG_PIRAL = debug === true ? '1.0' : debug; } if (emulator) { variables.DEBUG_PILET = emulator === true ? '/$pilet-api' : emulator; } const plugins = [new webpack_1.DefinePlugin((0, helpers_1.getDefineVariables)(variables))]; (0, helpers_1.setEnvironment)(variables); plugins.forEach(plugin => plugin.apply(compiler)); compiler.hooks.afterEnvironment.tap(pluginName, () => { }); } } exports.PiralInstanceWebpackPlugin = PiralInstanceWebpackPlugin; //# sourceMappingURL=index.js.map