Skip to content

Commit

Permalink
Add UMD build to dist (#260)
Browse files Browse the repository at this point in the history
* Add UMD build to dist

* Add commonjs+resolve plugins, misc formatting

* Fix package version
  • Loading branch information
eithe authored Apr 15, 2021
1 parent 7265ae3 commit 661d828
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 14 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
"ramdasauce": "^2.1.0",
"rollup": "^0.59.1",
"rollup-plugin-babel": "^3.0.4",
"rollup-plugin-commonjs": "^8.4.1",
"rollup-plugin-filesize": "^1.5.0",
"rollup-plugin-node-resolve": "^3.2.0",
"rollup-plugin-uglify": "^3.0.0",
"semantic-release": "^15.12.4",
"tslint": "^5.12.0",
Expand Down
59 changes: 45 additions & 14 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import babel from 'rollup-plugin-babel'
import uglify from 'rollup-plugin-uglify'
import commonjs from 'rollup-plugin-commonjs'
import filesize from 'rollup-plugin-filesize'
import resolve from 'rollup-plugin-node-resolve'
import uglify from 'rollup-plugin-uglify'

const externalModules = ['ramda', 'axios']
const input = 'lib/apisauce.js'
const name = 'apisauce'

function isImportExternal (importStr) {
let external = false
Expand All @@ -15,17 +19,44 @@ function isImportExternal (importStr) {
return external
}

export default {
input: 'lib/apisauce.js',
output: {
file: 'dist/apisauce.js',
format: 'cjs',
exports: 'named',
},
plugins: [
babel({ babelrc: false, plugins: ['ramda'] }),
uglify(),
filesize()
],
external: isImportExternal
function getBabelOptions () {
return { babelrc: false, plugins: ['ramda'] }
}

export default [
{
input,
output: {
exports: 'named',
file: `dist/${name}.js`,
format: 'cjs',
},
plugins: [
babel(getBabelOptions()),
uglify(),
filesize()
],
external: isImportExternal
},
{
input,
output: {
exports: 'named',
file: `dist/umd/${name}.js`,
format: 'umd',
globals: {
'ramda': 'ramda',
'axios': 'axios'
},
name,
},
plugins: [
babel(getBabelOptions()),
resolve(),
commonjs(),
uglify(),
filesize()
],
external: externalModules,
},
]

0 comments on commit 661d828

Please sign in to comment.