From 1be803dc2493c8d1e2edf0cd9307f4ee9f8f0bbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rouven=20We=C3=9Fling?= Date: Fri, 24 Aug 2018 13:23:55 +0200 Subject: [PATCH] Simplify rollup config --- rollup.config.js | 51 ++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/rollup.config.js b/rollup.config.js index f9cb433..3f61e8c 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -4,16 +4,18 @@ import commonjs from 'rollup-plugin-commonjs'; import {uglify} from 'rollup-plugin-uglify'; import babel from 'rollup-plugin-babel'; -function createConfig(file, opts = {}) { - const options = Object.assign({ - production: false, - uglify: false - }, opts); +function stripEnvVariables(production) { + return { + __DEV__: production ? 'false' : 'true', + 'process.env.NODE_ENV': production ? "'production'" : "'development'", + }; +} - const config = { +export default [ + { input: 'index.js', output: { - file: file, + file: 'prop-types.js', format: 'umd', name: 'PropTypes' }, @@ -25,23 +27,22 @@ function createConfig(file, opts = {}) { nodeResolve(), commonjs() ] - }; - - if (options.uglify) { - config.plugins.push(uglify()) + }, + { + input: 'index.js', + output: { + file: 'prop-types.min.js', + format: 'umd', + name: 'PropTypes' + }, + plugins: [ + babel({ + exclude: 'node_modules/**' + }), + replace(stripEnvVariables(options.production)), + nodeResolve(), + commonjs(), + uglify() + ] } - - return config; -} - -function stripEnvVariables(production) { - return { - __DEV__: production ? 'false' : 'true', - 'process.env.NODE_ENV': production ? "'production'" : "'development'", - }; -} - -export default [ - createConfig('prop-types.js'), - createConfig('prop-types.min.js', {uglify: true, production: true}) ];