npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

webpack-backup-output-plugin

v0.4.0

Published

Webpack plugin to create backup of and/or clean the output folder before files are emitted

Downloads

16

Readme

Webpack Backup Ouput Plugin

Webpack plugin to create backup of the output folder ("backup-folder/timestamp") upon first compile. Useful if your build is corrupted and you want to roll back to what you had before the compilation, but also if you just want to clean your directory before you emit the new files.

It supports multi webpack config instances which are run simultaneously, which means that the other webpack compilations won't emit files until the backup has been created and/or files have been deleted.

Note

The backup will only be performed once for each launch, which means that the backup will only be performed upon starting up a watch build. For subsequent build the backup will not be performed.

Warning

If you have activated removal of the output folder, you should activate the plugin for each build, otherwise the files and folders might be removed in the middle of files being emitted. If you give the same glob expression for files each build will wait for the clean to complete.

Install

npm

npm install --save-dev webpack-backup-output-plugin

Options

  • clean: [boolean=true] Remove the files in the output folder before emit
  • backup: [boolean=true] Backup files in the output folder
  • files: [string|string[]=**/*.*] Which files to backup and/or remove (glob expressions)
  • backupRoot: [string|boolean='_webpack-backup'] Folder where to put backups (relative to current work directory).

Usage

var WebpackBackupOutputPlugin = require('webpack-backup-output-plugin');

// In your webpack config
{
  // ...
  plugins: [
    new WebpackBackupOutputPlugin({ /* options */ })
  ]
}

Setup multi bundler config

Defining the plugin for several config that are run simultaneously is possible, but you should make sure to define what type of file you want to handle in the setup. But often you just want one config to handle the backup, so you just add it to one config

Example of multi config backup

// Config 1
const config1 = {
  output: {
    path: `/public`,
    filename: '[name].js?[chunkhash]'
  },
  // ...
  plugins: [
    new WebpackBackupOutputPlugin({
      files: ['**/*.png', '*.js']
    })
  ]
}

// Config 2
const config2 = {
  output: {
    // Same output path is needed to have it wait for the backup to complete
    path: `/public`,
  },
  // ...
  plugins: [
    new WebpackBackupOutputPlugin({
      files: '**/*.js'
    )
  ]
}

// Config 3 (not affected by the previous backups)
const config3 = {
  output: {
    // Having another path makes it ignore other backups
    // and only wait for its own backup to finish
    path: `/web`
  },
  // ...
  plugins: [
    new WebpackBackupOutputPlugin()
  ]
}

return [config1, config2, config3]