Skip to content

Commit

Permalink
feat: add cjs and es6 module output
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan DiMascio committed Jul 27, 2020
1 parent 573e546 commit 4330bed
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 10 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"name": "get-attributes",
"version": "0.0.0-development",
"description": "",
"main": "./dist/index.min.js",
"description": "A lightweight, fully-tested, zero-dependency module to make it easier to work with element attributes.",
"main": "./dist/index.js",
"module": "./dist/index.m.js",
"unpkg": "./dist/index.min.js",
"files": [
"dist"
Expand Down
46 changes: 38 additions & 8 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,30 @@
/* eslint-disable import/no-anonymous-default-export */

import path from 'path';
import {uglify} from 'rollup-plugin-uglify';
import {getBabelOutputPlugin} from '@rollup/plugin-babel';

import pkg from './package.json';

const config = {
input: 'src/index.js',
plugins: [],
output: {
exports: 'default',
sourcemap: true
}
};

const umd = {
...config,
output: {
...config.output,
file: pkg.unpkg,
format: 'umd',
name: 'getAttributes'
},
plugins: [
...config.plugins,
getBabelOutputPlugin({
configFile: path.resolve(__dirname, '.babelrc'),
allowAllFormats: true
Expand All @@ -16,13 +36,23 @@ const config = {
unsafe_comps: true // eslint-disable-line camelcase
}
})
],
output: {
exports: 'default',
file: 'dist/index.min.js',
format: 'umd',
name: 'getAttributes'
}
]
};

const web = {
...config,
output: [
{
...config.output,
file: pkg.main,
format: 'cjs'
},
{
...config.output,
file: pkg.module,
format: 'es'
}
]
};

export default config;
export default [umd, web];

0 comments on commit 4330bed

Please sign in to comment.