filemanager-webpack-plugin
Advanced tools
Comparing version 1.0.8 to 1.0.9
@@ -183,5 +183,18 @@ 'use strict'; | ||
}, { | ||
key: 'checkOptions', | ||
value: function checkOptions(stage) { | ||
var _this = this; | ||
if (this.options[stage] && Array.isArray(this.options[stage])) { | ||
this.options[stage].map(function (opts) { | ||
return _this.parseFileOptions(opts); | ||
}); | ||
} else { | ||
this.parseFileOptions(this.options[stage]); | ||
} | ||
} | ||
}, { | ||
key: 'parseFileOptions', | ||
value: function parseFileOptions(options) { | ||
var _this = this; | ||
var _this2 = this; | ||
@@ -203,3 +216,3 @@ var optKeys = Object.keys(options); | ||
cpr(command.source, command.destination, _this.cprOptions, function (err, files) { | ||
cpr(command.source, command.destination, _this2.cprOptions, function (err, files) { | ||
// handle error | ||
@@ -244,13 +257,11 @@ }); | ||
value: function apply(compiler) { | ||
var _this2 = this; | ||
var _this3 = this; | ||
compiler.plugin("compilation", function (comp) { | ||
if (_this2.options.verbose) { | ||
if (_this3.options.verbose) { | ||
console.log("FileManagerPlugin: onStart"); | ||
} | ||
if (_this2.options.onStart && Object.keys(_this2.options.onStart).length) { | ||
_this2.parseFileOptions(_this2.options.onStart); | ||
} | ||
_this3.checkOptions("onStart"); | ||
}); | ||
@@ -260,9 +271,7 @@ | ||
if (_this2.options.verbose) { | ||
if (_this3.options.verbose) { | ||
console.log("FileManagerPlugin: onEnd"); | ||
} | ||
if (_this2.options.onEnd && Object.keys(_this2.options.onEnd).length) { | ||
_this2.parseFileOptions(_this2.options.onEnd); | ||
} | ||
_this3.checkOptions("onEnd"); | ||
@@ -269,0 +278,0 @@ callback(); |
{ | ||
"name": "filemanager-webpack-plugin", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"description": "This Webpack plugin allows you to copy, move, delete files and directories before and after builds", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -51,2 +51,33 @@ | ||
If you need to preserve the order in which operations will run you can set the onStart and onEnd events to be Arrays. In this example below, in the onEnd event the copy action will run first, and then the delete after: | ||
```js | ||
const FileManagerPlugin = require('filemanager-webpack-plugin'); | ||
module.exports = { | ||
... | ||
... | ||
plugins: [ | ||
new FileManagerPlugin({ | ||
onEnd: [ | ||
{ | ||
copy: [ | ||
{ source: "./dist/bundle.js", destination: "./newfile.js" } | ||
] | ||
}, | ||
{ | ||
delete: [ | ||
"./dist/bundle.js" | ||
] | ||
} | ||
] | ||
}) | ||
], | ||
... | ||
} | ||
``` | ||
## Options | ||
@@ -53,0 +84,0 @@ |
@@ -39,2 +39,12 @@ const cpr = require('cpr'); | ||
checkOptions(stage) { | ||
if (this.options[stage] && Array.isArray(this.options[stage])) { | ||
this.options[stage].map(opts => this.parseFileOptions(opts)); | ||
} else { | ||
this.parseFileOptions(this.options[stage]); | ||
} | ||
} | ||
parseFileOptions(options) { | ||
@@ -103,2 +113,3 @@ | ||
apply(compiler) { | ||
@@ -112,5 +123,3 @@ | ||
if (this.options.onStart && Object.keys(this.options.onStart).length) { | ||
this.parseFileOptions(this.options.onStart); | ||
} | ||
this.checkOptions("onStart"); | ||
@@ -125,5 +134,3 @@ }); | ||
if (this.options.onEnd && Object.keys(this.options.onEnd).length) { | ||
this.parseFileOptions(this.options.onEnd); | ||
} | ||
this.checkOptions("onEnd"); | ||
@@ -130,0 +137,0 @@ callback(); |
@@ -28,2 +28,17 @@ const path = require('path'); | ||
} | ||
/* | ||
onEnd: [ | ||
{ | ||
copy: [ | ||
{ source: "./dist/bundle.js", destination: "./newfile.js" } | ||
] | ||
}, | ||
{ | ||
delete: [ | ||
"./dist/bundle.js" | ||
] | ||
} | ||
] | ||
*/ | ||
}), | ||
@@ -30,0 +45,0 @@ new webpack.HotModuleReplacementPlugin() |
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
21006
374
100