Skip to content

Commit

Permalink
Updating build system
Browse files Browse the repository at this point in the history
Now using babel and rollup, based on react-select
  • Loading branch information
JedWatson committed Oct 24, 2017
1 parent 845afc5 commit 641ea25
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 28 deletions.
14 changes: 14 additions & 0 deletions .babelrc
@@ -0,0 +1,14 @@
{
"presets": [
[
"env",
{
"targets": {
"browsers": ["last 2 versions", "ie 10"]
}
}
],
"react"
],
"plugins": ["transform-class-properties"]
}
5 changes: 5 additions & 0 deletions .eslintrc.js
@@ -0,0 +1,5 @@
module.exports = {
parser: 'babel-eslint',
extends: ['keystone-react'],
rules: { 'space-before-function-paren': 'off' },
};
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -13,3 +13,4 @@ coverage

# Dependency directory
node_modules
yarn.lock
54 changes: 26 additions & 28 deletions package.json
Expand Up @@ -2,7 +2,9 @@
"name": "react-hammerjs",
"version": "1.0.0",
"description": "ReactJS / HammerJS integration. Support touch events in your React app.",
"main": "src/Hammer.js",
"main": "lib/Hammer.js",
"jsnext:main": "dist/react-hammerjs.es.js",
"module": "dist/react-hammerjs.es.js",
"author": "Jed Watson",
"license": "MIT",
"repository": {
Expand All @@ -13,38 +15,34 @@
"hammerjs": "^2.0.8"
},
"devDependencies": {
"babel-preset-env": "^1.6.0",
"babel-cli": "^6.26.0",
"babel-eslint": "^8.0.1",
"babel-plugin-transform-class-properties": "^6.24.1",
"babelify": "^7.3.0",
"browserify": "^14.4.0",
"browserify-shim": "^3.8.12",
"chalk": "^1.1.3",
"del": "^2.2.1",
"gulp": "^3.9.1",
"gulp-bump": "^2.2.0",
"gulp-git": "^2.4.0",
"gulp-rename": "^1.2.2",
"gulp-streamify": "^1.0.2",
"gulp-uglify": "^1.5.4",
"gulp-util": "^3.0.7",
"merge-stream": "^1.0.0",
"react": "^16.0.0",
"react-dom": "^16.0.0",
"vinyl-source-stream": "^1.1.0"
"babel-plugin-transform-react-remove-prop-types": "^0.4.10",
"babel-preset-env": "^1.6.0",
"babel-preset-react": "^6.24.1",
"eslint": "^4.9.0",
"eslint-config-keystone": "^3.0.0",
"eslint-config-keystone-react": "^1.0.0",
"eslint-plugin-react": "^7.4.0",
"prop-types": "^15.6.0",
"rimraf": "^2.6.2",
"rollup": "^0.50.0",
"rollup-plugin-babel": "^3.0.2",
"rollup-plugin-node-resolve": "^3.0.0",
"rollup-plugin-uglify": "^2.0.1",
"uglify-es": "^3.1.5"
},
"peerDependencies": {
"react": "^0.14.3 || ^15.0.0 || ^16.0.0"
},
"browserify-shim": {
"react": "global:React",
"react-dom": "global:ReactDOM"
"react": "^0.14.9 || ^15.3.0 || ^16.0.0-rc || ^16.0",
"react-dom": "^0.14.9 || ^15.3.0 || ^16.0.0-rc || ^16.0"
},
"scripts": {
"build": "NODE_ENV=production gulp build",
"bump": "gulp bump",
"bump:minor": "gulp bump:minor",
"bump:major": "gulp bump:major",
"release": "gulp publish:tag && gulp publish:npm",
"build": "npm run build:clean && npm run build:lib && npm run build:dist",
"build:clean": "rimraf lib dist",
"build:lib": "babel src -d lib",
"build:dist": "rollup --config",
"lint": "eslint src",
"test": "echo \"no tests yet\" && exit 0"
},
"keywords": [
Expand Down
70 changes: 70 additions & 0 deletions rollup.config.js
@@ -0,0 +1,70 @@
import babel from 'rollup-plugin-babel';
import resolve from 'rollup-plugin-node-resolve';
import uglify from 'rollup-plugin-uglify';
import { minify } from 'uglify-es';

const name = 'Hammer';
const input = 'src/Hammer.js';
const output = 'dist/react-hammerjs';
const globals = {
'prop-types': 'PropTypes',
'react-dom': 'ReactDOM',
react: 'React',
};
const external = Object.keys(globals);
const babelOptions = production => {
let result = {
babelrc: false,
presets: [
[
'env',
{
modules: false,
targets: {
browsers: ['last 2 versions', 'ie 10'],
},
},
],
'react',
],
plugins: ['transform-class-properties'],
};
if (production) {
result.plugins.push('transform-react-remove-prop-types');
}
return result;
};

export default [
{
input: input,
output: {
file: output + '.es.js',
format: 'es',
},
external: external,
plugins: [babel(babelOptions(false))],
},
{
input: input,
output: {
name: name,
file: output + '.js',
format: 'umd',
},
globals: globals,
external: external,
plugins: [babel(babelOptions(false)), resolve()],
},
{
input: input,
output: {
name: name,
file: output + '.min.js',
format: 'umd',
},
globals: globals,
external: external,
plugins: [babel(babelOptions(true)), resolve(), uglify({}, minify)],
},
];

0 comments on commit 641ea25

Please sign in to comment.