-
Notifications
You must be signed in to change notification settings - Fork 356
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch the build process to rollup.js
Makes the minified UMD build 1.2kb smaller
- Loading branch information
1 parent
422a6a0
commit 392d770
Showing
3 changed files
with
142 additions
and
894 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import replace from 'rollup-plugin-replace'; | ||
import nodeResolve from 'rollup-plugin-node-resolve'; | ||
import commonjs from 'rollup-plugin-commonjs'; | ||
import uglify from 'rollup-plugin-uglify'; | ||
|
||
function createConfig(file, opts = {}) { | ||
const options = Object.assign({ | ||
production: false, | ||
uglify: false | ||
}, opts); | ||
|
||
const config = { | ||
input: 'index.js', | ||
output: { | ||
file: file, | ||
format: 'umd', | ||
name: 'PropTypes' | ||
}, | ||
plugins: [ | ||
replace(stripEnvVariables(options.production)), | ||
nodeResolve(), | ||
commonjs() | ||
] | ||
}; | ||
|
||
if (options.uglify) { | ||
config.plugins.push(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}) | ||
]; |
Oops, something went wrong.