Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@enonic/esbuild-plugin-copy-with-hash

Package Overview
Dependencies
Maintainers
4
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@enonic/esbuild-plugin-copy-with-hash

An esbuild plugin to copy files adding hash and making manifest.json

  • 0.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
4
Created
Source

esbuild-plugin-copy-with-hash

Installation

npm install --save-dev @enonic/esbuild-plugin-copy-with-hash

Usage

import esbuild from 'esbuild'
import copyWithHashPlugin from 'esbuild-plugin-copy-with-hash';

await esbuild.build({
	// ...
	plugins: [
		copyWithHashPlugin({
			context: 'node_modules',
			patterns: [
				'react/{cjs,umd}/*.js',
				'react-dom/{cjs,umd}/*.js',
			]
		})
	],
	// ...
})

Usage (tsup)

import copyWithHashPlugin from 'esbuild-plugin-copy-with-hash';

export default defineConfig((options) => {
	return {
		// ...
		esbuildPlugins: [
			copyWithHashPlugin({
				context: 'node_modules',
				patterns: [
					'react/{cjs,umd}/*.js',
					'react-dom/{cjs,umd}/*.js',
				]
			})
		],
		// ...
	}
}

Options

options?.addHashesToFileNames

Type: Boolean

Default: true

Whether or not to add the content hashes to the filenames. This option does NOT affect the content of the manifest file.

options?.context

Type: String

Default: ''

options?.context is relative to cwd().

options?.hash

Type: function

Default: (fileBuffer: Buffer) => bigint2base(xxh3.xxh64(fileBuffer), '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ')

The default hashing algorithm is xxh3.xxh64 with uppercase base36. This will typically yield a contenthash that is 12 to 13 characters long. You can provide your own hashing algorithm, keep in mind some filesystems are case "insensitive".

options?.manifest

Type: String

Default: 'manifest.json'

The path (relative to esbuildOptions.outdir joined with options?.to) to the generated manifest file.

options.patterns

Type: (string | { context?: string from: string to?: string })[]

A list of patterns (globs) to copy.

The glob is relative to cwd() joined with options?.context and pattern?.context.

The pattern?.to is relative to esbuildOptions.outdir joined with options?.to.

import esbuild from 'esbuild'
import copyWithHashPlugin from 'esbuild-plugin-copy-with-hash';

await esbuild.build({
	// ...
	plugins: [
		copyWithHashPlugin({
			context: 'node_modules',
			patterns: [
				'react/{cjs,umd}/*.js',
				{
					context: 'react-dom',
					from: '/{cjs,umd}/*.js',
					to: 'react-dom/'
				}
			],
			to: 'subdir'
		})
	],
	// ...
})

options?.to

Type: String

Default: ''

options?.to is relative to esbuildOptions.outdir.

License

MIT

Keywords

FAQs

Package last updated on 02 Nov 2023

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