0.0.9 • Published 2 years ago
npm-minify v0.0.9
Installation
npm install --global npm-minifyyarn global add npm-minify
What it does
- Deletes and recreates a
distdirectory in the root of your project - Recursively copies all the files you specify to
dist - Rewrites
package.jsonto removedevDependenciesandscripts, then minifies it - Rewrites
README, replacing a section marked# APIwith a link to your GitHub’sREADME
Npm-minify is non-destructive except for the dist directory.
What it doesn’t do
Minification of JavaScript or other assets. As package authors, we should assume that end users have their own build process and not publish pre-minified assets.
Usage
First, add a .npm-minify.js file to the root of your project, specifying which files should be copied (or not copied) to dist using a glob syntax. For example:
module.exports = {
"filter": [
"**/*.js",
"rng/hvml.rng",
"!**/*.test.js",
"!jest.config.js",
"!node_modules/**",
"!coverage/**",
"!dev.js",
"!.npm-minify.js",
]
};Then, when you’re ready to publish:
yarn version # or npm version
npm-minify
cd dist
npm publishAlternatively, you can specify the filter list as a comma-separated command-line argument:
npm-minify --filter '**/*.js,rng/hvml.rng,!**/*.test.js,!jest.config.js,!node_modules/**,!coverage/**,!dev.js,!.npm-minify.js'If you specify filter in both .npm-minify.js and as a command-line argument, npm-minify will combine the two.
If you specify no filter, then it defaults to copying over all .js files, while ignoring:
node_modules/coverage/test/.test.jsfiles.npm-minify.jsjest.config.js.eslintrc.jsfiles and their variants
Flags
| Flag | Shorthand | Description |
|---|---|---|
--verbose | -v | Turn on verbose console logging |
--filter | -f | Specify comma-separated list of files to include/exclude. Supports glob patterns. |
--in | -i | Specify minification source directory. |
--out | -o | Specify minifcation destination directory. |