UNPKG

piral-cli-webpack5

Version:

Provides debug and build capabilities for pilets and Piral instances using Webpack v5.

31 lines 1.3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const path_1 = require("path"); const webpack_1 = require("webpack"); const webpack_sources_1 = require("webpack-sources"); class SheetPlugin { constructor(cssName, piletName, entryName) { this.cssName = cssName; this.entryName = entryName; this.loaderPath = (0, path_1.resolve)(__dirname, `SheetLoader?cssName=${cssName}&piletName=${piletName}!`); } apply(compiler) { const { entry } = compiler.options; entry[this.entryName].import = [this.loaderPath, ...entry[this.entryName].import]; compiler.hooks.compilation.tap('SheetPlugin', (compilation) => { if (!compilation.compiler.parentCompilation) { compilation.hooks.processAssets.tap({ name: 'SheetPlugin', stage: webpack_1.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS, }, (assets) => { if (!assets[this.cssName]) { const source = new webpack_sources_1.RawSource(''); compilation.emitAsset(this.cssName, source); } }); } }); } } exports.default = SheetPlugin; //# sourceMappingURL=SheetPlugin.js.map