Skip to content

Commit

Permalink
Tweaked rollup setup + remade all tasks to npm scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Andarist committed May 3, 2017
1 parent a8ed08f commit 136a1a6
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 58 deletions.
51 changes: 0 additions & 51 deletions Makefile

This file was deleted.

File renamed without changes.
1 change: 1 addition & 0 deletions dist/react-textarea-autosize.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 19 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,23 @@
"keywords": "autosize, grow, react, react-component, textarea",
"repository": "andreypopp/react-textarea-autosize",
"license": "MIT",
"main": "lib/TextareaAutosize.js",
"module": "es/TextareaAutosize.js",
"jsnext:main": "es/TextareaAutosize.js",
"main": "lib/index.js",
"module": "es/index.js",
"jsnext:main": "es/index.js",
"author": "Andrey Popp <8mayday@gmail.com> (https://andreypopp.com/)",
"scripts": {
"prepublish": "make clean build || true"
"build": "npm run build:es && npm run build:cjs && npm run build:umd",
"build:es": "rimraf es && cross-env BABEL_ENV=es babel src --out-dir es --sourceMaps=inline",
"build:cjs": "rimraf lib && cross-env BABEL_ENV=cjs babel src --out-dir lib --sourceMaps=inline",
"build:umd": "rimraf dist && npm run build:umd:prod && npm run build:umd:dev",
"build:umd:prod": "cross-env BABEL_ENV=es NODE_ENV=production rollup -c -i src/index.js -o dist/react-textarea-autosize.min.js",
"build:umd:dev": "cross-env BABEL_ENV=es NODE_ENV=development rollup -c -i src/index.js -o dist/react-textarea-autosize.js",
"clean": "rimraf es && rimraf lib && rimraf dist",
"lint": "eslint src",
"prerelease": "npm run lint && npm run build",
"release:patch": "npm run prerelease && npm version patch && git push --follow-tags && npm publish",
"release:minor": "npm run prerelease && npm version minor && git push --follow-tags && npm publish",
"release:major": "npm run prerelease && npm version major && git push --follow-tags && npm publish"
},
"peerDependencies": {
"react": ">=0.14.0 <16.0.0"
Expand All @@ -27,8 +38,12 @@
"eslint-plugin-react": "^6.1.2",
"react": "^15.3.1",
"react-dom": "^15.3.1",
"rimraf": "^2.6.1",
"rollup": "^0.36.3",
"rollup-plugin-babel": "^2.7.1",
"rollup-plugin-node-resolve": "^3.0.0",
"rollup-plugin-replace": "^1.1.1",
"rollup-plugin-uglify": "^1.0.2",
"watchify": "^3.7.0"
},
"files": [
Expand Down
37 changes: 34 additions & 3 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
import nodeResolve from 'rollup-plugin-node-resolve';
import babel from 'rollup-plugin-babel';
import replace from 'rollup-plugin-replace';
import uglify from 'rollup-plugin-uglify';

export default {
entry: 'src/TextareaAutosize.js',
dest: 'dist/TextareaAutosize.min.js',
const env = process.env.NODE_ENV;

const config = {
format: 'umd',
moduleName: 'TextareaAutosize',
plugins: [
nodeResolve({
jsnext: true
}),
babel({
exclude: 'node_modules/**',
plugins: ['external-helpers'],
}),
replace({
'process.env.NODE_ENV': JSON.stringify(env)
})
],
external: [
'react', 'prop-types'
Expand All @@ -19,3 +28,25 @@ export default {
'prop-types': 'PropTypes'
},
};

if (env === 'production') {
config.plugins.push(
uglify({
compress: {
pure_getters: true,
unsafe: true,
unsafe_comps: true,
warnings: false,
screw_ie8: true
},
mangle: {
screw_ie8: true
},
output: {
screw_ie8: true
}
})
);
}

export default config;
File renamed without changes.

0 comments on commit 136a1a6

Please sign in to comment.