MovePlugin.js 330 B

12345678910111213141516
  1. const fs = require('fs-extra')
  2. module.exports = class MovePlugin {
  3. constructor (from, to) {
  4. this.from = from
  5. this.to = to
  6. }
  7. apply (compiler) {
  8. compiler.hooks.done.tap('move-plugin', () => {
  9. if (fs.existsSync(this.from)) {
  10. fs.moveSync(this.from, this.to, { overwrite: true })
  11. }
  12. })
  13. }
  14. }