rollup-plugin-filesize
Advanced tools
Comparing version 0.2.1 to 0.3.1
{ | ||
"name": "rollup-plugin-filesize", | ||
"version": "0.2.1", | ||
"version": "0.3.1", | ||
"description": "A rollup plugin to show filesize in the cli", | ||
@@ -8,5 +8,6 @@ "main": "dist/index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"test": "ava test/**/*.test.js", | ||
"build": "rollup -c", | ||
"prebuild": "rm -rf dist/*" | ||
"pretest": "npm run build", | ||
"prepublish": "npm run test" | ||
}, | ||
@@ -29,10 +30,21 @@ "repository": { | ||
"chalk": "^1.1.1", | ||
"filesize": "^3.2.0", | ||
"lodash": "^4.0.1" | ||
"deep-assign": "^2.0.0", | ||
"filesize": "^3.2.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "^0.11.0", | ||
"ava": "^0.13.0", | ||
"babel-preset-es2015": "^6.6.0", | ||
"babel-preset-es2015-rollup": "^1.1.1", | ||
"babel-register": "^6.7.2", | ||
"rollup-plugin-babel": "^2.3.9" | ||
}, | ||
"ava": { | ||
"require": "babel-register", | ||
"babel": "inherit" | ||
}, | ||
"babel": { | ||
"presets": [ | ||
"es2015" | ||
] | ||
} | ||
} |
@@ -5,2 +5,4 @@ # rollup-pugin-filesize | ||
![](screen.png) | ||
## Installation | ||
@@ -42,3 +44,3 @@ | ||
filesize( | ||
render : function (size){ | ||
render : function (options, size){ | ||
return size; | ||
@@ -45,0 +47,0 @@ } |
@@ -7,3 +7,4 @@ import babel from 'rollup-plugin-babel'; | ||
babel({ | ||
presets: [ 'es2015-rollup' ] | ||
babelrc:false, | ||
presets: [ 'es2015-rollup' ] | ||
}) | ||
@@ -10,0 +11,0 @@ ], |
import fileSize from 'filesize'; | ||
import boxen from 'boxen'; | ||
import Chalk from 'chalk'; | ||
import _ from 'lodash'; | ||
import deepAssign from 'deep-assign'; | ||
var chalk = new Chalk.constructor({enabled:true}); | ||
var chalk = new Chalk.constructor({ enabled: true }); | ||
export default function filesize(options = {}){ | ||
return { | ||
transformBundle(code){ | ||
export default function filesize (options = {}) { | ||
let defaultOptions = { | ||
format:{}, | ||
theme : 'dark', | ||
render:render | ||
}; | ||
function render (opt, size) { | ||
return opt.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 opts = _.defaultsDeep(options, defaultOptions); | ||
let defaultOptions = { | ||
format: {}, | ||
theme : 'dark', | ||
render: render | ||
}; | ||
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 opts = deepAssign({}, defaultOptions, options); | ||
if(options.render){ | ||
opts.render = options.render; | ||
} | ||
return { | ||
transformBundle(code){ | ||
let size = fileSize(Buffer.byteLength(code), opts.format); | ||
console.log(opts.render(size)) | ||
} | ||
} | ||
console.log(opts.render(opts, size)); | ||
return opts.render(opts, size); | ||
} | ||
} | ||
}; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
27564
8
74
1
63
5
+ Addeddeep-assign@^2.0.0
+ Addeddeep-assign@2.0.0(transitive)
+ Addedis-obj@1.0.1(transitive)
- Removedlodash@^4.0.1
- Removedlodash@4.17.21(transitive)