replaced webpack by rollup to reduce browser bundle size (-3kb)

This commit is contained in:
Camel Aissani 2016-09-15 19:16:42 +02:00
parent 12621d0883
commit a170883d93
10 changed files with 1490 additions and 1610 deletions

View File

@ -8,7 +8,7 @@
[![Code Climate](https://codeclimate.com/github/camelaissani/frontexpress/badges/gpa.svg)](https://codeclimate.com/github/camelaissani/frontexpress) [![Code Climate](https://codeclimate.com/github/camelaissani/frontexpress/badges/gpa.svg)](https://codeclimate.com/github/camelaissani/frontexpress)
[![Coverage Status](https://coveralls.io/repos/github/camelaissani/frontexpress/badge.svg?branch=master)](https://coveralls.io/github/camelaissani/frontexpress?branch=master) [![Coverage Status](https://coveralls.io/repos/github/camelaissani/frontexpress/badge.svg?branch=master)](https://coveralls.io/github/camelaissani/frontexpress?branch=master)
![Coverage Status](https://david-dm.org/camelaissani/frontexpress.svg) ![Coverage Status](https://david-dm.org/camelaissani/frontexpress.svg)
![Size Shield](https://img.shields.io/badge/size-14.4kb-brightgreen.svg) ![Size Shield](https://img.shields.io/badge/size-11.4kb-brightgreen.svg)
Code the front-end logic with the same style than on the back-end with express Code the front-end logic with the same style than on the back-end with express

View File

@ -21,7 +21,8 @@
"ignore": [ "ignore": [
"**/.*", "**/.*",
"index.js", "index.js",
"webpack.config.babel.js", "rollup.config.dev.js",
"rollup.config.prod.js",
"node_modules", "node_modules",
"bower_components", "bower_components",
"test", "test",

File diff suppressed because it is too large Load Diff

2
frontexpress.min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -12,7 +12,7 @@ import Middleware from './middleware';
* @private * @private
*/ */
class Route { export class Route {
/** /**

View File

@ -1,13 +1,13 @@
{ {
"name": "frontexpress", "name": "frontexpress",
"version": "0.1.9", "version": "0.1.10",
"description": "Frontexpress manages routes in browser like ExpressJS on Node", "description": "Frontexpress manages routes in browser like ExpressJS on Node",
"main": "dist/frontexpress.js", "main": "dist/frontexpress.js",
"scripts": { "scripts": {
"lint": "eslint .", "lint": "eslint .",
"only-test": "mocha --compilers js:babel-core/register", "only-test": "mocha --compilers js:babel-core/register",
"test": "npm run lint && babel-node node_modules/.bin/babel-istanbul cover node_modules/.bin/_mocha", "test": "npm run lint && babel-node node_modules/.bin/babel-istanbul cover node_modules/.bin/_mocha",
"frontpackage": "webpack", "frontpackage": "rollup -c rollup.config.dev.js && rollup -c rollup.config.prod.js",
"prepublish": "rimraf dist && babel lib -d dist" "prepublish": "rimraf dist && babel lib -d dist"
}, },
"author": "Camel Aissani <camel.aissani@gmail.com> (https://nuageprive.fr)", "author": "Camel Aissani <camel.aissani@gmail.com> (https://nuageprive.fr)",
@ -32,9 +32,8 @@
"babel-core": "^6.10.4", "babel-core": "^6.10.4",
"babel-eslint": "^6.1.2", "babel-eslint": "^6.1.2",
"babel-istanbul": "^0.11.0", "babel-istanbul": "^0.11.0",
"babel-loader": "^6.2.4",
"babel-plugin-add-module-exports": "^0.2.1", "babel-plugin-add-module-exports": "^0.2.1",
"babel-preset-es2015": "^6.9.0", "babel-preset-es2015-rollup": "^1.2.0",
"babel-register": "^6.14.0", "babel-register": "^6.14.0",
"chai": "^3.5.0", "chai": "^3.5.0",
"eslint": "^3.1.0", "eslint": "^3.1.0",
@ -43,7 +42,10 @@
"istanbul": "^0.4.4", "istanbul": "^0.4.4",
"mocha": "^2.5.3", "mocha": "^2.5.3",
"rimraf": "^2.5.3", "rimraf": "^2.5.3",
"rollup": "^0.35.10",
"rollup-plugin-babel": "^2.6.1",
"rollup-plugin-uglify": "^1.0.1",
"sinon": "^1.17.4", "sinon": "^1.17.4",
"webpack": "^1.13.1" "uglify-js": "^2.7.3"
} }
} }

13
rollup.config.dev.js Normal file
View File

@ -0,0 +1,13 @@
import babel from 'rollup-plugin-babel';
import uglify from 'rollup-plugin-uglify';
export default {
entry: 'lib/frontexpress.js',
format: 'umd',
moduleName:'frontexpress',
plugins: [babel({
babelrc: false,
presets: ['es2015-rollup']
})],
dest: 'frontexpress.js'
};

14
rollup.config.prod.js Normal file
View File

@ -0,0 +1,14 @@
import babel from 'rollup-plugin-babel';
import uglify from 'rollup-plugin-uglify';
export default {
entry: 'lib/frontexpress.js',
format: 'umd',
sourceMap: true,
moduleName:'frontexpress',
plugins: [babel({
babelrc: false,
presets: ['es2015-rollup']
}), uglify()],
dest: 'frontexpress.min.js'
};

View File

@ -1,29 +0,0 @@
import webpack from 'webpack';
import path from 'path';
const script = (name, min=false) => {
return {
entry: path.join(__dirname, 'index.js'),
output: {
path: __dirname,
filename: min?`${name}.min.js`:`${name}.js`
},
devtool: min?'source-map':null,
module: {
loaders: [{
test: /\.js/,
loader: 'babel-loader'
}]
},
plugins: !min?[]:[
new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin(),
],
};
};
export default [
script('frontexpress'),
script('frontexpress', true)
];