Skip to content
The require hook will bind itself to node's require and automatically uglify files on the fly.
JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github
test
.editorconfig
.eslintignore
.eslintrc
.gitignore
.npmrc
.nycrc
.travis.yml
CHANGELOG.md
LICENSE
README.md
api.js
index.js
package.json

README.md

uglify-register Version Badge

Build Status dependency status dev dependency status License Downloads

npm badge

Use this require hook to uglify JS files on-the-fly.

This is particularly useful when trying to replicate production minification effects in a dev or test environment.

Not recommended for a production environment, like all require hooks.

Install

npm install --save-dev uglify-register

Usage

With no extra uglify options; only for the .js extension; for all files:

require('uglify-register');

With custom uglify options:

require('uglify-register/api')({
	uglify: {
		mangle: true // for example
	},
});

With custom file extensions:

require('uglify-register/api')({
	extensions: ['.js', '.jsx'], // defaults to just ".js" if omitted
});

Excluding files that match provided regular expressions:

require('uglify-register/api')({
	exclude: [
		/\/node_modules\/, // third-party code
		/\/test\//, // code under a "test" dir
		\/some-special-file.js$\/, // some file
	],
});

All options can of course be combined.

Tests

Simply clone the repo, npm install, and run npm test

You can’t perform that action at this time.