2
0
mirror of https://github.com/tenrok/maska.git synced 2026-05-15 11:59:38 +03:00
Files
maska/rollup.config.js
T
Vinicius Reis 636a46cbc0 ♻️ use rollup instead of webpack
allow build process to generate esm and umd packages
2020-03-10 14:10:05 -03:00

54 lines
1.1 KiB
JavaScript

import babel from 'rollup-plugin-babel';
import { terser } from "rollup-plugin-terser";
const { version } = require('./package.json')
const isProduction = process.env.NODE_ENV === 'production'
const useBabel = process.env.DISABLE_BABEL !== 'yes'
const banner = `/*!
* maska v${version}
* (c) 2019-${(new Date()).getFullYear()} Alexander Shabunevich
* Released under the MIT License.
*/`
const getDistFolder = (fileName = '') => `dist/${useBabel ? '' : 'es6/'}${fileName}`
const makeFileName = (format) => getDistFolder(`maska.${format}.js`)
const makeOutputConfig = (format = true) => {
return {
banner,
format,
file: makeFileName(format),
name: 'Maska'
}
}
const plugins = [
useBabel && babel({
exclude: 'node_modules/**'
}),
isProduction && terser()
].filter(Boolean)
export default {
input: 'src/index.js',
plugins,
output: [
{
...makeOutputConfig('esm')
},
{
...makeOutputConfig('umd'),
exports: 'named',
},
{
...makeOutputConfig('umd'),
file: getDistFolder('maska.js'),
exports: 'named',
},
],
watch: {
exclude: 'node_modules/**'
}
};