Package Exports
- pull-minify-js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (pull-minify-js) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
pull-minify-js
Minify JavaScript files or buffers inside a pull-stream
Minifies streamed JavaScript files using uglify-js
const pull = require('pull-stream')
const { read, write } = require('pull-files')
const minify = require('pull-minify-js')
pull(
read([ 'index.js', 'test.js' ], { cwd: __dirname }),
minify({
mangle: true,
toplevel: true
}),
write(__dirname + '/out', err => {
// done
})
)
Use minify.buffer
if you are streaming JavaScript buffers instead
pull(
readFile(__dirname + '/foo.js'),
minify.buffer({ mangle: true, toplevel: true }),
writeFile(__dirname + '/out.js')
)
Install
npm install --save pull-minify-js
yarn add pull-minify-js
Usage
minify(options?)
A stream that maps each JavaScript file to the minified version. See uglify-js
's options further configuration.
pull(
read([ 'index.js', 'lib/**/*.js' ], { cwd: __dirname }),
bundle('app.js', [ 'es2040' ]),
uglify({ ...options }),
write(__dirname + '/out', err => {
// ...
})
)
You can make it map all files regardless of extensions, by passing strict: false
minify({ strict: false, ... })
minify.buffer(options?)
The base implementation that compiles buffer to buffer, instead of file to file. Options are the same
pull(
readFile(__dirname + '/foo.js'),
minify.buffer({ ...options }),
writeFile(__dirname + '/foo.min.js')
)
Maintained by Jamen Marz (See on Twitter and GitHub for questions & updates)