Skip to content

Commit

Permalink
build: update config
Browse files Browse the repository at this point in the history
  • Loading branch information
fengyuanchen committed Jan 23, 2021
1 parent 656fdd5 commit 30b026c
Showing 1 changed file with 33 additions and 18 deletions.
51 changes: 33 additions & 18 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,54 +1,69 @@
const babel = require('rollup-plugin-babel');
const changeCase = require('change-case');
const commonjs = require('rollup-plugin-commonjs');
const createBanner = require('create-banner');
const nodeResolve = require('rollup-plugin-node-resolve');
const pkg = require('./package');
import babel from '@rollup/plugin-babel';
import changeCase from 'change-case';
import commonjs from '@rollup/plugin-commonjs';
import createBanner from 'create-banner';
import nodeResolve from '@rollup/plugin-node-resolve';
import { terser } from 'rollup-plugin-terser';
import pkg from './package.json';

const name = changeCase.pascalCase(pkg.name);
const banner = createBanner({
case: 'PascalCase',
data: {
year: '2014-present',
},
template: 'inline',
});
const globals = {
jquery: 'jQuery',
};

module.exports = {
export default {
input: 'src/index.js',
output: [
{
banner,
name,
file: `dist/${pkg.name}.js`,
globals,
file: pkg.browser,
format: 'umd',
},
{
banner,
name,
file: pkg.browser.replace(/(\.js)$/, '.min$1'),
globals,
format: 'umd',
globals: {
jquery: 'jQuery',
},
compact: true,
plugins: [
terser(),
],
},
{
banner,
file: `dist/${pkg.name}.common.js`,
file: pkg.main,
format: 'cjs',
exports: 'auto',
},
{
banner,
file: `dist/${pkg.name}.esm.js`,
file: pkg.module,
format: 'esm',
},
{
banner,
name,
file: `docs/js/${pkg.name}.js`,
globals,
file: pkg.browser.replace(/^dist/, 'docs/js'),
format: 'umd',
globals: {
jquery: 'jQuery',
},
},
],
external: ['jquery'],
plugins: [
nodeResolve(),
commonjs(),
babel(),
babel({
babelHelpers: 'bundled',
}),
],
};

0 comments on commit 30b026c

Please sign in to comment.