Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
goto-bus-stop committed Oct 10, 2017
0 parents commit 9b388da
Show file tree
Hide file tree
Showing 6 changed files with 163 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Logs
logs
*.log

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
language: node_js
node_js:
- 8
- 6
- 4
cache:
directories:
- ~/.npm
15 changes: 15 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# [Apache License 2.0](https://spdx.org/licenses/Apache-2.0)

Copyright 2017 Renée Kooi <renee@kooi.me>

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

> http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
36 changes: 36 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
var packFlat = require('browser-pack-flat/plugin')
var commonShake = require('common-shakeify')
var unassertify = require('unassertify')
var uglify = require('minify-stream')
var envify = require('envify/custom')
var uglifyify = require('uglifyify')

module.exports = function (b, opts) {
var env = Object.assign({
NODE_ENV: 'production'
}, process.env)

// Remove `assert()` calls.
b.transform(unassertify, { global: true })
// Replace `process.env.NODE_ENV` with "production".
b.transform(envify(env), { global: true })
// Remove dead code.
b.transform(uglifyify, {
global: true,
toplevel: true,
// No need to mangle here, will do that at the end.
mangle: false
})

// Output a flat bundle, without function wrappers for each module.
b.plugin(packFlat)
// Remove unused exports from modules.
b.plugin(commonShake)

// Minify the final output.
var uglifyOpts = {}
if (!b._options.debug) {
uglifyOpts.sourceMap = false
}
b.pipeline.get('pack').push(uglify(uglifyOpts))
}
37 changes: 37 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"name": "tinyify",
"description": "a browserify plugin that runs various optimizations, so you don't have to install them all manually.",
"version": "0.0.0",
"author": "Renée Kooi <renee@kooi.me>",
"bugs": {
"url": "https://github.com/goto-bus-stop/tinyify/issues"
},
"dependencies": {
"browser-pack-flat": "^2.7.2",
"common-shakeify": "^0.4.1",
"envify": "^4.1.0",
"minify-stream": "^1.1.0",
"uglifyify": "^4.0.4",
"unassertify": "^2.0.4"
},
"devDependencies": {
"standard": "^10.0.3"
},
"homepage": "https://github.com/goto-bus-stop/tinyify",
"keywords": [
"browserify",
"minify",
"optimize",
"tree-shaking",
"uglify"
],
"license": "Apache-2.0",
"main": "index.js",
"repository": {
"type": "git",
"url": "https://github.com/goto-bus-stop/tinyify.git"
},
"scripts": {
"test": "standard"
}
}
40 changes: 40 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# tinyify

a browserify plugin that runs various optimizations, so you don't have to install them all manually.

[![npm][npm-image]][npm-url]
[![travis][travis-image]][travis-url]
[![standard][standard-image]][standard-url]

[npm-image]: https://img.shields.io/npm/v/browserify-tiny.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/browserify-tiny
[travis-image]: https://img.shields.io/travis/goto-bus-stop/browserify-tiny.svg?style=flat-square
[travis-url]: https://travis-ci.org/goto-bus-stop/browserify-tiny
[standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square
[standard-url]: http://npm.im/standard

```bash
npm install --saved-dev tinyify

browserify -p tinyify app.js
```

## Included

- [unassertify][] - Remove `assert()` calls
- [envify][] - Replace environment variables—by default, replaces `NODE_ENV` with `"production"`
- [uglifyify][] - Remove dead code from modules
- [common-shakeify][] - Remove unused exports from modules
- [browser-pack-flat][] - Output a "flat" bundle, with all modules in a single scope
- [minify-stream][] - Uglify the final bundle

## License

[Apache-2.0](./LICENSE.md)

[unassertify]: https://github.com/unassert-js/unassertify
[envify]: https://github.com/hughsk/envify
[uglifyify]: https://github.com/hughsk/uglifyify
[common-shakeify]: https://github.com/goto-bus-stop/common-shakeify
[browser-pack-flat]: https://github.com/goto-bus-stop/browser-pack-flat
[minify-stream]: https://github.com/goto-bus-stop/minify-stream

0 comments on commit 9b388da

Please sign in to comment.