Skip to content

Commit

Permalink
Simplify rollup config
Browse files Browse the repository at this point in the history
  • Loading branch information
realityking committed Aug 24, 2018
1 parent 577d559 commit 1be803d
Showing 1 changed file with 26 additions and 25 deletions.
51 changes: 26 additions & 25 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
},
Expand All @@ -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})
];

0 comments on commit 1be803d

Please sign in to comment.