Skip to content

Commit

Permalink
Merge pull request #2003 from jochenberger/strip-proptypes-in-production
Browse files Browse the repository at this point in the history
strip proptypes in production build (fixes #1882)
  • Loading branch information
JedWatson authored Sep 24, 2017
2 parents 105275b + 5da115a commit 7523c20
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"babel-loader": "^7.1.1",
"babel-plugin-external-helpers": "^6.22.0",
"babel-plugin-istanbul": "^4.1.4",
"babel-plugin-transform-react-remove-prop-types": "^0.4.8",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
Expand Down
20 changes: 13 additions & 7 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,16 @@ const globals = {
react: 'React',
};
const external = Object.keys(globals);
const babelOptions = {
babelrc: false,
presets: [['es2015', { modules: false }], 'stage-0', 'react'],
plugins: ['external-helpers'],
const babelOptions = (production) => {
let result = {
babelrc: false,
presets: [['es2015', { modules: false }], 'stage-0', 'react'],
plugins: ['external-helpers'],
};
if (production) {
result.plugins.push('transform-react-remove-prop-types');
};
return result;
};

export default [
Expand All @@ -27,7 +33,7 @@ export default [
format: 'es',
},
external: external,
plugins: [babel(babelOptions)],
plugins: [babel(babelOptions(false))],
},
{
input: 'src/index.umd.js',
Expand All @@ -38,7 +44,7 @@ export default [
},
globals: globals,
external: external,
plugins: [babel(babelOptions), resolve()],
plugins: [babel(babelOptions(false)), resolve()],
},
{
input: 'src/index.umd.js',
Expand All @@ -49,6 +55,6 @@ export default [
},
globals: globals,
external: external,
plugins: [babel(babelOptions), resolve(), uglify({}, minify)],
plugins: [babel(babelOptions(true)), resolve(), uglify({}, minify)],
},
];

0 comments on commit 7523c20

Please sign in to comment.