├── .editorconfig ├── .eslintrc.json ├── .gitignore ├── LICENSE.md ├── README.md ├── index.js └── package.json /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | indent_style = space 7 | indent_size = 4 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [package.json] 12 | indent_style = space 13 | indent_size = 2 14 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "env": { 4 | "node": true 5 | }, 6 | "extends": [ 7 | "@vimeo/eslint-config-player/es6", 8 | "plugin:ava/recommended" 9 | ], 10 | "plugins": ["ava"], 11 | "rules": { 12 | "ava/no-cb-test": "error" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .DS_Store 3 | .idea 4 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 [Vimeo](https://vimeo.com) 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # rollup-plugin-bundle-size [![npm](https://img.shields.io/npm/v/rollup-plugin-bundle-size.svg?maxAge=2592000)](https://www.npmjs.com/package/rollup-plugin-bundle-size) 2 | 3 | > A rollup plugin to show the size of the generated bundle(s). 4 | 5 | ## Sample Output 6 | 7 | ```bash 8 | $ rollup -c 9 | src/project.js → dist/project.bundle.js... 10 | Created bundle project.bundle.js: 52.53 kB → 18.29 kB (gzip) 11 | created dist/project.bundle.js in 3.5s 12 | ``` 13 | 14 | ## Installation 15 | 16 | ```bash 17 | npm install --save-dev rollup-plugin-bundle-size 18 | ``` 19 | 20 | ## Usage 21 | 22 | ### JS API 23 | 24 | ```js 25 | const rollup = require('rollup'); 26 | const bundleSize = require('rollup-plugin-bundle-size'); 27 | 28 | rollup.rollup({ 29 | entry: 'src/index.js', 30 | plugins: [ 31 | bundleSize() 32 | ] 33 | }).then((bundle) => { 34 | ... 35 | }); 36 | ``` 37 | 38 | ### Config File 39 | 40 | ```js 41 | import bundleSize from 'rollup-plugin-bundle-size'; 42 | 43 | export default { 44 | entry: 'src/index.js', 45 | plugins: [ 46 | bundleSize() 47 | ] 48 | } 49 | ``` 50 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const chalk = require('chalk'); 3 | const maxmin = require('maxmin'); 4 | 5 | module.exports = function() { 6 | return { 7 | name: 'rollup-plugin-bundle-size', 8 | generateBundle(options, bundle) { 9 | const asset = path.basename(options.file); 10 | const size = maxmin(bundle[asset].code, bundle[asset].code, true); 11 | console.log(`Created bundle ${chalk.cyan(asset)}: ${size.substr(size.indexOf(' → ') + 3)}`); 12 | } 13 | }; 14 | }; 15 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "rollup-plugin-bundle-size", 3 | "version": "1.0.3", 4 | "description": "Output the size of your bundle", 5 | "main": "index.js", 6 | "author": "Brad Dougherty ", 7 | "license": "MIT", 8 | "repository": "vimeo/rollup-plugin-bundle-size", 9 | "bugs": "https://github.com/vimeo/rollup-plugin-bundle-size/issues", 10 | "homepage": "https://github.com/vimeo/rollup-plugin-bundle-size", 11 | "keywords": [ 12 | "rollup-plugin" 13 | ], 14 | "scripts": { 15 | "test": "eslint index.js test.js" 16 | }, 17 | "dependencies": { 18 | "chalk": "^1.1.3", 19 | "maxmin": "^2.1.0" 20 | }, 21 | "devDependencies": { 22 | "@vimeo/eslint-config-player": "^4.0.1", 23 | "eslint": "^3.3.1" 24 | } 25 | } 26 | --------------------------------------------------------------------------------