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

@wecdev/webpack-hook-attacher-plugin

v5740.0.6

Published

With this plugin you can attach own or predefined file/directory (copy, create, rename, merge, replace in etc...) or predefined system (sleep, run process, etc...) operations to any webpack hook. We created this plugin because it is difficult to find file

Downloads

20

Readme

webpack-hook-attacher-plugin Summary

With this plugin you can attach own or predefined file/directory (copy, create, rename, merge, replace in etc...) or predefined system (sleep, run process, etc...) operations to any webpack hook. We created this plugin because it is difficult to find file operation webpack plugins that runs in the proper phase of our buid process: delete build folder, copy files BEFORE the build process, copy files, replace in files, merge JSON files, zip build folder AFTER build process.

Install

npm i @wecdev/webpack-hook-attacher-plugin --save-dev

I know I can do better :)

If you have found bug or need an additional operation don't hesitate to contact me.

Copyright & Support

Copyright (c) 2022, Roland Szikora. You can support this package at https://www.patreon.com/rolandszik

Licensing

This project run under AGPL-3.0

Full license https://www.gnu.org/licenses/agpl-3.0.txt

TLDR https://tldrlegal.com/license/gnu-affero-general-public-license-v3-(agpl-3.0)

Use Operations

You can attach predefined operations to any webpack hook during the webpack or webpack-dev-server build file operations or system operations

such as

  • create file/directory
  • delete files/directories
  • move files/directories
  • modify file content (delete/add rows, replace in files)
  • merge json files
  • zip directories
  • run process
  • sleep
  • wait until conditions is met

Usage

Webpack.config.js:

Version numbers

The version number keeps up with the webpack versioning: the first number is the concatenated current webpack version number, then MINOR then PATCH version of the module :)

[CURRENT_WEBPACK_VERSION].MAJOR.PATCH

5740.0.0 means it belongs to the 5.74.0 webpack 6010.0.0 means it belongs to the 6.1.0 webpack

Write your own operation

You can write your own operation if you like. Create your Operation file (derive from Operation class) and override the abtract run method

Example

import * as fsExtra from 'fs-extra';

import { SingleSourceOperationParameter, SingleSourceOperation, ISingleSourceOperationParameter } from './single-source-operation';
import { Utils } from '@wecdev/webpack-hook-attacher-plugin';

export interface IMoveSingleFileParameter extends ISingleSourceOperationParameter {
    sourceFilePath: string;
    destinationFilePath: string;
    overwrite?: boolean;
}

export class MoveSingleFileParameter extends SingleSourceOperationParameter implements IMoveSingleFileParameter {
    //IMoveSingleFileParameter
    public sourceFilePath: string = null;
    public destinationFilePath: string = null;
    public overwrite?: boolean = true;
    //SingleSourceOperationParameter
    public getSingleSource(): string {
        return this.sourceFilePath;
    }
}

export class MoveSingleFile extends SingleSourceOperation {

    constructor(userParams: IMoveSingleFileParameter) {
        super();
        this.params = Utils.mergeUserSettingsToDeafultSetting(userParams, new MoveSingleFileParameter());
        super.setParams(this.params);
        this.moveOptions = { overwrite: this.params.overwrite };
    }

    public name: string = 'MoveSingleFile';

    public params: MoveSingleFileParameter;

    private moveOptions: fsExtra.MoveOptions;

    public run(): void {
        super.runSingleFileOperationIfExists(this.funcionToRun.bind(this));
    }

    private funcionToRun(sourceFilePath: string): void {
        this.ensureDestinationFileDirectoryExists(this.params.destinationFilePath);
        fsExtra.moveSync(sourceFilePath, this.params.destinationFilePath, this.moveOptions);
    }
}