Skip to content

Commit

Permalink
Merge pull request #10 from davidnguyen179/enhancement/add_min_main_file
Browse files Browse the repository at this point in the history
support minify umd format
  • Loading branch information
davidnguyen11 authored Feb 5, 2019
2 parents 47bfa22 + 3b88029 commit 20c6a85
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 21 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,14 @@
"rimraf": "^2.6.2",
"rollup": "^1.1.2",
"rollup-plugin-babel": "^4.3.2",
"rollup-plugin-terser": "^4.0.4",
"sinon": "^4.0.2"
},
"scripts": {
"prebuild": "rimraf dist/*",
"start": "react-scripts start",
"build": "rollup --config",
"postbuild": "BUILD_MINIFY=true rollup --config",
"start": "react-scripts start",
"test": "react-scripts test --env=jsdom",
"coverage": "npm test -- --coverage",
"eject": "react-scripts eject",
Expand Down
55 changes: 35 additions & 20 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,43 @@
import babel from 'rollup-plugin-babel';
import { terser } from 'rollup-plugin-terser';

const isMinify = process.env.BUILD_MINIFY ? true : false;

let output = [
{
file: 'dist/react-paginating.cjs.js',
name: 'react-paginating-cjs',
format: 'cjs'
},
{
file: 'dist/react-paginating.esm.js',
name: 'react-paginating-esm',
format: 'esm'
},
{
file: 'dist/react-paginating.umd.js',
name: 'react-paginating-umd',
format: 'umd',
sourcemap: true
},
];

if (isMinify) {
output = {
file: 'dist/react-paginating.umd.min.js',
name: 'react-paginating.umd.min',
format: 'iife',
sourcemap: true
};
}

export default [{
input: 'src/Pagination/index.js',
output: [
{
file: 'dist/react-paginating.cjs.js',
name: 'react-paginating-cjs',
format: 'cjs'
},
{
file: 'dist/react-paginating.umd.js',
name: 'react-paginating-umd',
format: 'umd',
sourcemap: true
},
{
file: 'dist/react-paginating.esm.js',
name: 'react-paginating-esm',
format: 'esm'
}
],
output,
plugins: [
babel({
exclude: 'node_modules/**'
})
]
}),
isMinify ? terser() : null
]
}];

0 comments on commit 20c6a85

Please sign in to comment.