New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

copy-asset-in-memory-webpack-plugin

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

copy-asset-in-memory-webpack-plugin

Copy assets in webpack memory

  • 4.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
703
decreased by-40.17%
Maintainers
1
Weekly downloads
 
Created
Source

copy-asset-in-memory-webpack-plugin

Tests License Version Node Version Webpack Version

Copy assets in webpack memory

Getting Started

Installation

npm i -D copy-asset-in-memory-webpack-plugin
# or
yarn add --dev copy-asset-in-memory-webpack-plugin

Usage

// webpack.config.js
const CopyAssetInMemoryPlugin = require("copy-asset-in-memory-webpack-plugin");

module.exports = {
  plugins: [
    new CopyAssetInMemoryPlugin({
      test: /.js$/,
      to: "js",
    }),
  ],
};

Options

test

Include all assets that pass test assertion

Type: String|RegExp|Array<String|RegExp>. Default: undefined

include

Include all assets matching any of these conditions

Type: String|RegExp|Array<String|RegExp>. Default: undefined

exclude

Exclude all assets matching any of these conditions

Type: String|RegExp|Array<String|RegExp>. Default: undefiend

stage

Refer https://webpack.js.org/api/compilation-hooks/#processassets for more info.

// webpack.config.js
const { Compilation } = require("webpack");
const CopyAssetInMemoryPlugin = require("copy-asset-in-memory-webpack-plugin");

module.exports = {
  plugins: [
    new CopyAssetInMemoryPlugin({
      test: /.js$/,
      stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE, // Default
      to: (fileName) => `${js}/filename`,
    }),
  ],
};
to

Asset destination, allows to modify the file path.

Type: Function | string. Default: undefined

// webpack.config.js
const CopyAssetInMemoryPlugin = require("copy-asset-in-memory-webpack-plugin");

module.exports = {
  plugins: [
    new CopyAssetInMemoryPlugin({
      test: /.js$/,
      to: (fileName) => `${js}/filename`, // copies all files into `js` folder
    }),
    new CopyAssetInMemoryPlugin({
      test: /.svg$/,
      to: "assets", // copies all files into `assets` folder
    }),
  ],
};
transform

Allows to modify the file contents.

Type: Function. Default: undefined

// webpack.config.js
const CopyAssetInMemoryPlugin = require("copy-asset-in-memory-webpack-plugin");

module.exports = {
  plugins: [
    new CopyAssetInMemoryPlugin({
      test: /.js$/,
      to: (fileName) => `${js}/filename`,
      // The `content` argument is a [`Buffer`](https://nodejs.org/api/buffer.html) object
      // it could be converted to a `String` to be processed using `content.toString()`
      transform: (content) => "newContent",
    }),
  ],
};
deleteOriginalAssets

Whether to delete the original assets or not.

Type: boolean. Default: false

Caveats

  • assets cannot be copied outside output directory
  • deleting an asset via deleteOriginalAssets will also delete its sourcemap

Keywords

FAQs

Package last updated on 31 Dec 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc