UNPKG

kuyin-webpack-plugins

Version:

custom webpack, enhanced-resolve plugins

23 lines (22 loc) 829 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); class ChangeAssetsPathWebpackPlugin { constructor(options) { this.options = options; } apply(compiler) { const { assetsPath, ignore } = this.options; compiler.hooks.emit.tapAsync('ChangeAssetsPathWebpackPlugin', (compilation, callback) => { Object.keys(compilation.assets).forEach(key => { if (ignore !== undefined && ignore.test(key)) { return; } const newKey = `${assetsPath}/${key}`; compilation.assets[newKey] = compilation.assets[key]; delete compilation.assets[key]; }); callback(); }); } } exports.ChangeAssetsPathWebpackPlugin = ChangeAssetsPathWebpackPlugin;