mirror of https://github.com/webpack/webpack.git
(fix): pr comments
This commit is contained in:
parent
d35cf1e056
commit
ee0c891c67
|
@ -423,6 +423,21 @@ export type ChunkLoadTimeout = number;
|
|||
* The global variable used by webpack for loading of chunks.
|
||||
*/
|
||||
export type ChunkLoadingGlobal = string;
|
||||
/**
|
||||
* Clean the output directory before emit.
|
||||
*/
|
||||
export type CleanPlugin =
|
||||
| boolean
|
||||
| {
|
||||
/**
|
||||
* Log the assets that should be removed instead of delete them.
|
||||
*/
|
||||
dry?: boolean;
|
||||
/**
|
||||
* Not delete the assets, that matches to this regexp or a function.
|
||||
*/
|
||||
ignore?: RegExp | ((asset: string) => boolean);
|
||||
};
|
||||
/**
|
||||
* Check if to be emitted file already exists and have the same content before writing to output filesystem.
|
||||
*/
|
||||
|
@ -1735,7 +1750,7 @@ export interface Output {
|
|||
/**
|
||||
* Clean the output directory before emit.
|
||||
*/
|
||||
clean?: boolean | CleanPlugin;
|
||||
clean?: CleanPlugin;
|
||||
/**
|
||||
* Check if to be emitted file already exists and have the same content before writing to output filesystem.
|
||||
*/
|
||||
|
@ -1889,23 +1904,6 @@ export interface Output {
|
|||
*/
|
||||
workerWasmLoading?: WasmLoading;
|
||||
}
|
||||
/**
|
||||
* Clean the output directory before emit.
|
||||
*/
|
||||
export interface CleanPlugin {
|
||||
/**
|
||||
* Log the assets that should be removed instead of delete them.
|
||||
*/
|
||||
dry?: boolean;
|
||||
/**
|
||||
* Is clean enabled.
|
||||
*/
|
||||
enabled?: boolean;
|
||||
/**
|
||||
* Not delete the assets, that matches to this regexp or a function.
|
||||
*/
|
||||
ignore?: RegExp | ((asset: string) => boolean);
|
||||
}
|
||||
/**
|
||||
* The abilities of the environment where the webpack generated code should run.
|
||||
*/
|
||||
|
|
|
@ -9,10 +9,6 @@ export interface CleanPluginArgument {
|
|||
* Log the assets that should be removed instead of delete them.
|
||||
*/
|
||||
dry?: boolean;
|
||||
/**
|
||||
* Is clean enabled.
|
||||
*/
|
||||
enabled?: boolean;
|
||||
/**
|
||||
* Not delete the assets, that matches to this regexp or a function.
|
||||
*/
|
||||
|
|
|
@ -63,8 +63,8 @@ class CleanPlugin {
|
|||
}
|
||||
|
||||
/** @param {CleanPluginArgument} [options] options */
|
||||
constructor(options) {
|
||||
this.options = Object.assign({ enabled: true, dry: false }, options || {});
|
||||
constructor(options = {}) {
|
||||
this.options = { dry: false, ...options };
|
||||
|
||||
if (options && typeof options === "object") {
|
||||
validate(schema, options, {
|
||||
|
@ -174,7 +174,7 @@ class CleanPlugin {
|
|||
|
||||
if (this.ignoreList.some(ignore => checkToIgnore(ignore, child))) {
|
||||
if (this.options.dry) {
|
||||
this.logger.info(`[${child}] was ignored`);
|
||||
this.logger.info(`[${child}] will be ignored in non-dry mode`);
|
||||
}
|
||||
|
||||
return callback();
|
||||
|
@ -188,7 +188,9 @@ class CleanPlugin {
|
|||
if (stat.isFile()) {
|
||||
if (this.fsState.files.has(child)) {
|
||||
if (this.options.dry) {
|
||||
this.logger.info(`[${child}] was ignored`);
|
||||
this.logger.info(
|
||||
`[${child}] will be ignored in non-dry mode`
|
||||
);
|
||||
}
|
||||
|
||||
return callback();
|
||||
|
|
|
@ -168,7 +168,9 @@ class WebpackOptionsApply extends OptionsApply {
|
|||
|
||||
if (options.output.clean) {
|
||||
const CleanPlugin = require("./CleanPlugin");
|
||||
new CleanPlugin(options.output.clean).apply(compiler);
|
||||
new CleanPlugin(
|
||||
options.output.clean === true ? {} : options.output.clean
|
||||
).apply(compiler);
|
||||
}
|
||||
|
||||
if (options.devtool) {
|
||||
|
|
|
@ -251,10 +251,7 @@ const getNormalizedWebpackOptions = config => {
|
|||
chunkLoading: output.chunkLoading,
|
||||
chunkLoadingGlobal: output.chunkLoadingGlobal,
|
||||
chunkLoadTimeout: output.chunkLoadTimeout,
|
||||
clean:
|
||||
typeof output.clean === "boolean"
|
||||
? { enabled: output.clean }
|
||||
: output.clean,
|
||||
clean: output.clean,
|
||||
compareBeforeEmit: output.compareBeforeEmit,
|
||||
crossOriginLoading: output.crossOriginLoading,
|
||||
devtoolFallbackModuleFilenameTemplate:
|
||||
|
|
|
@ -130,31 +130,34 @@
|
|||
},
|
||||
"CleanPlugin": {
|
||||
"description": "Clean the output directory before emit.",
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"dry": {
|
||||
"description": "Log the assets that should be removed instead of delete them.",
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "boolean"
|
||||
},
|
||||
"enabled": {
|
||||
"description": "Is clean enabled.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"ignore": {
|
||||
"description": "Not delete the assets, that matches to this regexp or a function.",
|
||||
"anyOf": [
|
||||
{
|
||||
"instanceof": "RegExp",
|
||||
"tsType": "RegExp"
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"dry": {
|
||||
"description": "Log the assets that should be removed instead of delete them.",
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"instanceof": "Function",
|
||||
"tsType": "((asset:string) => boolean)"
|
||||
"ignore": {
|
||||
"description": "Not delete the assets, that matches to this regexp or a function.",
|
||||
"anyOf": [
|
||||
{
|
||||
"instanceof": "RegExp",
|
||||
"tsType": "RegExp"
|
||||
},
|
||||
{
|
||||
"instanceof": "Function",
|
||||
"tsType": "((asset:string) => boolean)"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"CompareBeforeEmit": {
|
||||
"description": "Check if to be emitted file already exists and have the same content before writing to output filesystem.",
|
||||
|
@ -1908,15 +1911,7 @@
|
|||
"$ref": "#/definitions/ChunkLoadingGlobal"
|
||||
},
|
||||
"clean": {
|
||||
"description": "Clean the output directory before emit.",
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/CleanPlugin"
|
||||
}
|
||||
]
|
||||
"$ref": "#/definitions/CleanPlugin"
|
||||
},
|
||||
"compareBeforeEmit": {
|
||||
"$ref": "#/definitions/CompareBeforeEmit"
|
||||
|
|
|
@ -7,10 +7,6 @@
|
|||
"description": "Log the assets that should be removed instead of delete them.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"enabled": {
|
||||
"description": "Is clean enabled.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"ignore": {
|
||||
"description": "Not delete the assets, that matches to this regexp or a function.",
|
||||
"anyOf": [
|
||||
|
|
|
@ -2133,19 +2133,6 @@ Object {
|
|||
"multiple": false,
|
||||
"simpleType": "boolean",
|
||||
},
|
||||
"output-clean-enabled": Object {
|
||||
"configs": Array [
|
||||
Object {
|
||||
"description": "Is clean enabled.",
|
||||
"multiple": false,
|
||||
"path": "output.clean.enabled",
|
||||
"type": "boolean",
|
||||
},
|
||||
],
|
||||
"description": "Is clean enabled.",
|
||||
"multiple": false,
|
||||
"simpleType": "boolean",
|
||||
},
|
||||
"output-clean-ignore": Object {
|
||||
"configs": Array [
|
||||
Object {
|
||||
|
|
|
@ -1002,19 +1002,23 @@ declare interface CleanPluginArgument {
|
|||
*/
|
||||
dry?: boolean;
|
||||
|
||||
/**
|
||||
* Is clean enabled.
|
||||
*/
|
||||
enabled?: boolean;
|
||||
|
||||
/**
|
||||
* Not delete the assets, that matches to this regexp or a function.
|
||||
*/
|
||||
ignore?: RegExp | ((asset: string) => boolean);
|
||||
}
|
||||
declare class CleanPluginClass {
|
||||
constructor(options: CleanPluginArgument);
|
||||
options: { enabled: boolean; dry: boolean } & CleanPluginArgument;
|
||||
constructor(options?: CleanPluginArgument);
|
||||
options: {
|
||||
/**
|
||||
* Log the assets that should be removed instead of delete them.
|
||||
*/
|
||||
dry: boolean;
|
||||
/**
|
||||
* Not delete the assets, that matches to this regexp or a function.
|
||||
*/
|
||||
ignore?: RegExp | ((asset: string) => boolean);
|
||||
};
|
||||
ignoreList: (RegExp | ((arg0: string) => boolean))[];
|
||||
logger: WebpackLogger;
|
||||
fs: OutputFileSystem;
|
||||
|
@ -1035,26 +1039,18 @@ declare interface CleanPluginCompilationHooks {
|
|||
void
|
||||
>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean the output directory before emit.
|
||||
*/
|
||||
declare interface CleanPluginWebpackOptions {
|
||||
/**
|
||||
* Log the assets that should be removed instead of delete them.
|
||||
*/
|
||||
dry?: boolean;
|
||||
|
||||
/**
|
||||
* Is clean enabled.
|
||||
*/
|
||||
enabled?: boolean;
|
||||
|
||||
/**
|
||||
* Not delete the assets, that matches to this regexp or a function.
|
||||
*/
|
||||
ignore?: RegExp | ((asset: string) => boolean);
|
||||
}
|
||||
type CleanPluginWebpackOptions =
|
||||
| boolean
|
||||
| {
|
||||
/**
|
||||
* Log the assets that should be removed instead of delete them.
|
||||
*/
|
||||
dry?: boolean;
|
||||
/**
|
||||
* Not delete the assets, that matches to this regexp or a function.
|
||||
*/
|
||||
ignore?: RegExp | ((asset: string) => boolean);
|
||||
};
|
||||
declare interface CodeGenerationContext {
|
||||
/**
|
||||
* the dependency templates
|
||||
|
@ -6153,7 +6149,7 @@ declare interface Output {
|
|||
/**
|
||||
* Clean the output directory before emit.
|
||||
*/
|
||||
clean?: boolean | CleanPluginWebpackOptions;
|
||||
clean?: CleanPluginWebpackOptions;
|
||||
|
||||
/**
|
||||
* Check if to be emitted file already exists and have the same content before writing to output filesystem.
|
||||
|
|
Loading…
Reference in New Issue