-
Notifications
You must be signed in to change notification settings - Fork 358
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
cfc7f43
commit 284a163
Showing
3 changed files
with
216 additions
and
866 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,47 @@ | ||
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'; | ||
import babel from 'rollup-plugin-babel'; | ||
|
||
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(), | ||
babel({ | ||
exclude: 'node_modules/**' | ||
}) | ||
] | ||
}; | ||
|
||
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.