Skip to content

Commit

Permalink
Add build:umd command using rollup
Browse files Browse the repository at this point in the history
See #454
  • Loading branch information
dhleong committed Sep 2, 2018
1 parent eb19f50 commit c5c8952
Show file tree
Hide file tree
Showing 3 changed files with 357 additions and 10 deletions.
9 changes: 9 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"size:why": "size-limit --why packages/react-swipeable-views/lib/index.js",
"watch": "lerna exec --concurrency 99 -- babel src --out-dir lib --watch",
"build": "rm -rf packages/*/lib && cross-env NODE_ENV=production lerna exec -- babel --config-file ../../babel.config.js src --out-dir lib --ignore test.js",
"build:umd": "rm -rf packages/*/lib && cross-env BABEL_ENV=rollup rollup -c",
"release": "yarn build && yarn lerna exec yarn prepublish && lerna publish",
"postrelease": "yarn docs:deploy"
},
Expand All @@ -30,6 +31,7 @@
"devDependencies": {
"@babel/cli": "7.0.0",
"@babel/core": "7.0.0",
"@babel/plugin-external-helpers": "7.0.0",
"@babel/plugin-transform-object-assign": "7.0.0",
"@babel/plugin-transform-runtime": "7.0.0",
"@babel/preset-react": "7.0.0",
Expand Down Expand Up @@ -79,6 +81,13 @@
"react": "^16.3.0",
"react-dom": "^16.3.0",
"recompose": "^0.29.0",
"rollup": "^0.64.1",
"rollup-plugin-babel": "^4.0.0-beta.8",
"rollup-plugin-commonjs": "^9.1.0",
"rollup-plugin-includepaths": "^0.2.3",
"rollup-plugin-node-resolve": "^3.3.0",
"rollup-plugin-replace": "^2.0.0",
"rollup-plugin-uglify": "^3.0.0",
"sinon": "^6.0.0",
"size-limit": "^0.19.0",
"webpack": "4.16.3",
Expand Down
87 changes: 87 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import includePaths from 'rollup-plugin-includepaths';
import nodeResolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import babel from 'rollup-plugin-babel';
import replace from 'rollup-plugin-replace';
import uglify from 'rollup-plugin-uglify';

// './packages/react-swipeable-views-core/src/index.js',
// './packages/react-swipeable-views-utils/src/index.js',

export default {
input: './packages/react-swipeable-views/src/index.js',
output: {
file: 'lib/umd/react-swipeable-views.js',
format: 'umd',
name: 'SwipeableViews',
globals: {
react: 'React',
'react-dom': 'ReactDOM',
},
},
external: ['react', 'react-dom'],
plugins: [
nodeResolve(),
includePaths({
include: {
'react-swipeable-views-core': 'packages/react-swipeable-views-core/src/index.js',
'react-swipeable-views-utils': 'packages/react-swipeable-views-utils/src/index.js',
},
}),
commonjs({
include: [
'node_modules/**',
'packages/react-swipeable-views/node_modules/**',
'packages/react-swipeable-views-core/node_modules/**',
'packages/react-swipeable-views-utils/node_modules/**',
],
}),
babel({
exclude: 'node_modules/**',
babelrc: false,
plugins: [
'@babel/plugin-transform-object-assign',
['@babel/transform-runtime', { polyfill: false, useBuiltIns: true }],
'transform-react-constant-elements',
'transform-dev-warning',
[
'transform-react-remove-prop-types',
{
mode: 'wrap',
},
],
// NOTE: rollup warns against using this, but
// it doesn't work without:
'@babel/plugin-external-helpers',
],
presets: [
[
'@babel/preset-env',
{
targets: {
ie: 11,
edge: 14,
firefox: 45,
chrome: 49,
safari: 10,
node: '6.11',
},
modules: false,
},
],
['@babel/preset-stage-1', { loose: true }],
'@babel/preset-react',
],
}),
replace({
'process.env.NODE_ENV': JSON.stringify('development'),
}),
uglify({
mangle: false,
output: {
comments: true,
beautify: true,
},
}),
],
};
Loading

0 comments on commit c5c8952

Please sign in to comment.