From ea629b384caf6ca229f96fc548afd6d47e93859f Mon Sep 17 00:00:00 2001 From: Moritz Gunz Date: Mon, 26 Feb 2018 18:13:16 +0100 Subject: [PATCH] :memo: Display bundle size badge --- .gitignore | 3 ++- .npmignore | 5 +++++ README.md | 7 +++---- package.json | 15 ++++++--------- rollup.config.js | 25 +++++++++---------------- yarn.lock | 8 ++++++++ 6 files changed, 33 insertions(+), 30 deletions(-) create mode 100644 .npmignore diff --git a/.gitignore b/.gitignore index 670d0c6..88a2e51 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ dist/ node_modules/ -.rpt2_cache/ \ No newline at end of file +.rpt2_cache/ +.tmp/ \ No newline at end of file diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..1cb798b --- /dev/null +++ b/.npmignore @@ -0,0 +1,5 @@ +.idea/ +.rpt2_cache/ + +.editorconfig +.travis.yml \ No newline at end of file diff --git a/README.md b/README.md index 0e2a115..570af30 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,14 @@ # 💪 fit-html [![Travis](https://img.shields.io/travis/Festify/fit-html.svg)](https://travis-ci.org/Festify/fit-html) +![Bundle Size](http://img.badgesize.io/https://unpkg.com/fit-html/.tmp/index.min.js?compression=gzip) [![Greenkeeper badge](https://badges.greenkeeper.io/Festify/fit-html.svg)](https://greenkeeper.io/) -5KB web components + lit-html + redux library without bloat. +3KB web components + lit-html + redux library without bloat. ## Overview -fit-html is a combination of [lit-html](https://github.com/Polymer/lit-html), web components and [redux](http://redux.js.org/) bringing efficient rendering and a functional application architecture together. Yet, the total size of the framework is below 5KB1, including dependencies. +fit-html is a combination of [lit-html](https://github.com/Polymer/lit-html), web components and [redux](http://redux.js.org/) bringing efficient rendering and a functional application architecture together. Yet, the total size of the framework is below 3KB, including dependencies. ## Small Example @@ -89,5 +90,3 @@ Please see https://github.com/Festify/fit-html-demo for more and larger examples ## License MIT - -1: fit-html weighs in at about 3.2kb right now diff --git a/package.json b/package.json index acf3baa..a7fe828 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fit-html", - "version": "0.5.1", + "version": "0.5.2", "description": "5KB functional Web Components without bloat", "main": "dist/index.js", "types": "dist/index.d.ts", @@ -10,12 +10,8 @@ "private": false, "bundlesize": [ { - "path": "dist/bundle.min.js", - "maxSize": "2 kb" - }, - { - "path": "dist/bundle+deps.min.js", - "maxSize": "5 kb" + "path": ".tmp/index.min.js", + "maxSize": "3 kb" } ], "devDependencies": { @@ -25,6 +21,7 @@ "rollup-plugin-babel-minify": "^4.0.0", "rollup-plugin-commonjs": "^8.3.0", "rollup-plugin-node-resolve": "^3.0.3", + "rollup-plugin-replace": "^2.0.0", "rollup-plugin-typescript2": "^0.11.1", "tslint": "^5.9.1", "typescript": "^2.5.3" @@ -34,8 +31,8 @@ "redux": "^3.7.2" }, "scripts": { - "build": "yarn lint && tsc", - "check-size": "rollup -c && bundlesize && rm dist/bundle*", + "build": "yarn lint && tsc && NODE_ENV=production rollup -c", + "check-size": "yarn build && bundlesize", "fix": "tslint -p tsconfig.json --fix", "lint": "tslint -p tsconfig.json" } diff --git a/rollup.config.js b/rollup.config.js index 3bd405d..e82ad41 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,31 +1,24 @@ import minify from 'rollup-plugin-babel-minify'; import cjs from 'rollup-plugin-commonjs'; import nodeResolve from 'rollup-plugin-node-resolve'; +import replace from 'rollup-plugin-replace'; import typescript from 'rollup-plugin-typescript2'; -export default [{ +export default { input: 'src/index.ts', output: { - file: 'dist/bundle.min.js', - format: 'es', - sourcemap: false, - }, - plugins: [ // No nodeResolve here to avoid bundling dependencies - typescript(), - cjs(), - minify({ comments: false }), - ], -}, { - input: 'src/index.ts', - output: { - file: 'dist/bundle+deps.min.js', - format: 'es', + file: '.tmp/index.min.js', + format: 'umd', + name: 'FitHtml', sourcemap: false, }, plugins: [ nodeResolve({ browser: true }), typescript(), cjs(), + replace({ + 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'develop'), + }), minify({ comments: false }), ], -}]; \ No newline at end of file +}; \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 033db41..6929c1d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1724,6 +1724,14 @@ rollup-plugin-node-resolve@^3.0.3: is-module "^1.0.0" resolve "^1.1.6" +rollup-plugin-replace@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/rollup-plugin-replace/-/rollup-plugin-replace-2.0.0.tgz#19074089c8ed57184b8cc64e967a03d095119277" + dependencies: + magic-string "^0.22.4" + minimatch "^3.0.2" + rollup-pluginutils "^2.0.1" + rollup-plugin-typescript2@^0.11.1: version "0.11.1" resolved "https://registry.yarnpkg.com/rollup-plugin-typescript2/-/rollup-plugin-typescript2-0.11.1.tgz#c308de734baaed8ed8316dc8501a82a0ced674f4"