Socket
Socket
Sign inDemoInstall

rollup-plugin-filesize

Package Overview
Dependencies
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rollup-plugin-filesize - npm Package Compare versions

Comparing version 0.1.1 to 0.2.1

28

dist/index.js

@@ -8,2 +8,3 @@ 'use strict';

var Chalk = _interopDefault(require('chalk'));
var _ = _interopDefault(require('lodash'));

@@ -13,9 +14,26 @@ var chalk = new Chalk.constructor({ enabled: true });

function filesize() {
return {
transformBundle: function transformBundle(code) {
console.log(boxen(chalk.green.bold('Bundle size : ') + chalk.yellow.bold(fileSize(Buffer.byteLength(code))), { padding: 1 }));
}
};
var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
return {
transformBundle: function transformBundle(code) {
var defaultOptions = {
format: {},
theme: 'dark',
render: render
};
var opts = _.defaultsDeep(options, defaultOptions);
function render(size) {
return opts.theme == 'dark' ? boxen(chalk.green.bold('Bundle size : ') + chalk.yellow.bold(size), { padding: 1 }) : boxen(chalk.black.bold('Bundle size : ') + chalk.blue.bold(size), { padding: 1 });
}
var size = fileSize(Buffer.byteLength(code), opts.format);
console.log(opts.render(size));
}
};
};
module.exports = filesize;

7

package.json
{
"name": "rollup-plugin-filesize",
"version": "0.1.1",
"version": "0.2.1",
"description": "A rollup plugin to show filesize in the cli",
"main": "dist/index.js",
"jsnext:main" : "src/index.js",
"jsnext:main": "src/index.js",
"scripts": {

@@ -28,3 +28,4 @@ "test": "echo \"Error: no test specified\" && exit 1",

"chalk": "^1.1.1",
"filesize": "^3.2.0"
"filesize": "^3.2.0",
"lodash": "^4.0.1"
},

@@ -31,0 +32,0 @@ "devDependencies": {

@@ -25,4 +25,37 @@ # rollup-pugin-filesize

## options
#### format
type : `object`
default : {}
See the options [here](https://github.com/avoidwork/filesize.js)
#### render
type : `function`
return the command that you want to log. Eg:
```js
filesize(
render : function (size){
return size;
}
)
```
#### theme
type: `string`
default : 'dark'
options : 'dark'/'light'
choose based on your terminal theme.
## License
MIT
import babel from 'rollup-plugin-babel';
export default {
external: [ 'filesize', 'boxen', 'chalk' ],
external: [ 'filesize', 'boxen', 'chalk', 'lodash' ],
plugins: [

@@ -6,0 +6,0 @@ babel({

import fileSize from 'filesize';
import boxen from 'boxen';
import Chalk from 'chalk';
import _ from 'lodash';
var chalk = new Chalk.constructor({enabled:true});
export default function filesize(){
export default function filesize(options = {}){
return {
transformBundle(code){
console.log(boxen(chalk.green.bold('Bundle size : ') + chalk.yellow.bold(fileSize(Buffer.byteLength(code))), {padding:1}));
let defaultOptions = {
format:{},
theme : 'dark',
render:render
};
let opts = _.defaultsDeep(options, defaultOptions);
function render(size){
return opts.theme == 'dark' ? (
boxen(chalk.green.bold('Bundle size : ') + chalk.yellow.bold(size), { padding: 1 })
) : (
boxen(chalk.black.bold('Bundle size : ') + chalk.blue.bold(size), { padding: 1 })
);
}
let size = fileSize(Buffer.byteLength(code), opts.format);
console.log(opts.render(size))
}
}
};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc