ignore-emit-webpack-plugin
Advanced tools
Comparing version 2.0.3 to 2.0.4
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.IgnoreEmitPlugin = void 0; | ||
var IgnoreEmitPlugin = /** @class */function () { | ||
@@ -54,3 +55,3 @@ function IgnoreEmitPlugin(ignoreRegex, options) { | ||
}; | ||
// webpack 4 | ||
// webpack 4/5 | ||
if (compiler.hooks && compiler.hooks.emit) { | ||
@@ -61,2 +62,3 @@ compiler.hooks.emit.tap('IgnoreEmitPlugin', ignoreAssets); | ||
else { | ||
// @ts-ignore - this signature does not exist on the latest webpack typing | ||
compiler.plugin('emit', function (compilation, callback) { | ||
@@ -63,0 +65,0 @@ ignoreAssets(compilation); |
@@ -1,2 +0,2 @@ | ||
import { Compiler } from "webpack"; | ||
import { Compiler } from 'webpack'; | ||
declare class IgnoreEmitPlugin { | ||
@@ -3,0 +3,0 @@ private readonly options; |
26
index.js
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.IgnoreEmitPlugin = void 0; | ||
var webpack_1 = require("webpack"); | ||
var IgnoreEmitPlugin = /** @class */ (function () { | ||
@@ -47,12 +49,28 @@ function IgnoreEmitPlugin(ignoreRegex, options) { | ||
_this.DEBUG && console.log("IgnoreEmitPlugin: Ignoring asset " + assetName); | ||
delete compilation.assets[assetName]; | ||
if (typeof compilation.deleteAsset === 'function') { | ||
// Webpack 5 | ||
compilation.deleteAsset(assetName); | ||
} | ||
else { | ||
// older versions | ||
delete compilation.assets[assetName]; | ||
} | ||
} | ||
}); | ||
}; | ||
// webpack 4 | ||
if (compiler.hooks && compiler.hooks.emit) { | ||
compiler.hooks.emit.tap('IgnoreEmitPlugin', ignoreAssets); | ||
// webpack 4/5 | ||
if (compiler.hooks && compiler.hooks.compilation) { | ||
// compiler.hooks.emit.tap('IgnoreEmitPlugin', ignoreAssets); | ||
compiler.hooks.compilation.tap('IgnoreEmitPlugin', function (compilation) { | ||
compilation.hooks.processAssets.tap({ | ||
name: 'IgnoreEmitPlugin', | ||
stage: webpack_1.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS | ||
}, function () { | ||
ignoreAssets(compilation); | ||
}); | ||
}); | ||
} | ||
// webpack 3 | ||
else { | ||
// @ts-ignore - this signature does not exist on the latest webpack typing | ||
compiler.plugin('emit', function (compilation, callback) { | ||
@@ -59,0 +77,0 @@ ignoreAssets(compilation); |
34
index.ts
'use strict'; | ||
import {Compiler} from "webpack"; | ||
import * as webpack from "webpack"; | ||
import Compilation = webpack.compilation.Compilation; | ||
import {Compilation, Compiler} from 'webpack'; | ||
@@ -54,3 +52,9 @@ class IgnoreEmitPlugin { | ||
this.DEBUG && console.log(`IgnoreEmitPlugin: Ignoring asset ${assetName}`); | ||
delete compilation.assets[assetName]; | ||
if (typeof compilation.deleteAsset === 'function') { | ||
// Webpack 5 | ||
compilation.deleteAsset(assetName); | ||
} else { | ||
// older versions | ||
delete compilation.assets[assetName]; | ||
} | ||
} | ||
@@ -60,8 +64,24 @@ }); | ||
// webpack 4 | ||
if (compiler.hooks && compiler.hooks.emit) { | ||
compiler.hooks.emit.tap('IgnoreEmitPlugin', ignoreAssets); | ||
// webpack 4/5 | ||
if (compiler.hooks && compiler.hooks.compilation) { | ||
// compiler.hooks.emit.tap('IgnoreEmitPlugin', ignoreAssets); | ||
compiler.hooks.compilation.tap( | ||
'IgnoreEmitPlugin', | ||
(compilation: Compilation) => { | ||
compilation.hooks.processAssets.tap( | ||
{ | ||
name: 'IgnoreEmitPlugin', | ||
stage: Compilation.PROCESS_ASSETS_STAGE_ADDITIONS | ||
}, | ||
() => { | ||
ignoreAssets(compilation); | ||
} | ||
); | ||
} | ||
); | ||
} | ||
// webpack 3 | ||
else { | ||
// @ts-ignore - this signature does not exist on the latest webpack typing | ||
compiler.plugin('emit', (compilation, callback) => { | ||
@@ -68,0 +88,0 @@ ignoreAssets(compilation); |
{ | ||
"name": "ignore-emit-webpack-plugin", | ||
"version": "2.0.3", | ||
"version": "2.0.4", | ||
"description": "Prevents ignored files from being emitted during a Webpack build", | ||
"scripts": { | ||
"test:webpack": "bash test/test.sh && bash test/test-webpack3.sh && bash test/test-webpack4.sh", | ||
"test:webpack": "bash test/test.sh && bash test/test-webpack3.sh && bash test/test-webpack4.sh && bash test/test-webpack5.sh", | ||
"test:unit": "node test/test-api.js", | ||
"test": "npm run test:unit && npm run test:webpack", | ||
"test": "npm -s run test:unit && npm -s run test:webpack", | ||
"build": "tsc", | ||
"build:watch": "tsc --watch", | ||
"transpile": "mkdir -p es5 && babel index.js --out-file es5/index.js --presets=es2015", | ||
@@ -28,9 +29,8 @@ "publishOnly": "npm run build && npm run transpile && npm run test" | ||
"devDependencies": { | ||
"@types/webpack": "^4.41.21", | ||
"babel-cli": "^6.26.0", | ||
"babel-preset-es2015": "^6.24.1", | ||
"typescript": "^3.8.3", | ||
"webpack": "latest", | ||
"typescript": "^4.0.3", | ||
"webpack": ">=5.2.0", | ||
"webpack-cli": "latest" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17150
5
9
263