primevue-mirror/rollup.config.js

126 lines
3.7 KiB
JavaScript
Raw Normal View History

2021-01-18 08:25:54 +00:00
import vue from 'rollup-plugin-vue';
import postcss from 'rollup-plugin-postcss';
2021-01-18 12:21:54 +00:00
import { terser } from 'rollup-plugin-terser';
2021-01-18 08:25:54 +00:00
const fs = require('fs-extra');
const path = require('path');
let entries = [];
2021-01-18 14:35:36 +00:00
let globalDependencies = {
'vue': 'Vue',
'primevue/ripple': 'primevue.ripple',
'primevue/utils': 'primevue.utils',
'primevue/button': 'primevue.button',
'primevue/inputtext': 'primevue.inputtext',
'primevue/dialog': 'primevue.dialog',
'primevue/paginator': 'primevue.paginator',
'primevue/confirmationeventbus': 'primevue.confirmationeventbus',
'primevue/toasteventbus': 'primevue.toasteventbus',
'primevue/useconfirm': 'primevue.useconfirm',
'primevue/usetoast': 'primevue.usetoast',
'primevue/progressbar': 'primevue.progressbar',
'primevue/message': 'primevue.message',
'primevue/dropdown': 'primevue.dropdown',
'primevue/menu': 'primevue.menu',
'@fullcalendar/core': 'FullCalendar'
}
function addEntry(folder, inFile, outFile) {
entries.push({
input: 'src/components/' + folder + '/' + inFile,
output: [
2021-01-18 12:21:54 +00:00
{
format: 'cjs',
file: 'dist/' + folder + '/' + outFile + '.cjs.js',
2021-01-18 12:21:54 +00:00
},
{
format: 'esm',
file: 'dist/' + folder + '/' + outFile + '.esm.js'
},
{
2021-01-18 12:21:54 +00:00
format: 'iife',
2021-01-18 14:35:36 +00:00
name: 'primevue.' + folder,
2021-01-18 13:41:06 +00:00
file: 'dist/' + folder + '/' + outFile + '.js',
2021-01-18 14:35:36 +00:00
globals: globalDependencies
2021-01-18 12:21:54 +00:00
}
],
plugins: [
vue(),
postcss()
]
});
entries.push({
2021-01-18 12:21:54 +00:00
input: 'src/components/' + folder + '/' + inFile,
output: [
{
format: 'cjs',
file: 'dist/' + folder + '/' + outFile + '.cjs.min.js'
2021-01-18 12:21:54 +00:00
},
{
format: 'esm',
file: 'dist/' + folder + '/' + outFile + '.esm.min.js'
},
{
format: 'iife',
2021-01-18 13:41:06 +00:00
name: folder,
file: 'dist/' + folder + '/' + outFile + '.min.js',
globals: globalDependencies
}
],
plugins: [
vue(),
2021-01-18 12:21:54 +00:00
postcss(),
terser()
]
});
}
function addSFC() {
fs.readdirSync(path.resolve(__dirname, './src/components/')).forEach(folder => {
fs.readdirSync(path.resolve(__dirname, './src/components/' + folder)).forEach(file => {
2021-01-18 08:25:54 +00:00
let name = file.split(/(.vue)$|(.js)$/)[0].toLowerCase();
if (/\.vue$/.test(file) && (name === folder)) {
addEntry(folder, file, name);
2021-01-18 08:25:54 +00:00
}
});
2021-01-18 08:25:54 +00:00
});
}
function addDirectives() {
addEntry('badgedirective', 'BadgeDirective.js', 'badgedirective');
addEntry('ripple', 'Ripple.js', 'ripple');
addEntry('tooltip', 'Tooltip.js', 'tooltip');
}
function addConfig() {
addEntry('config', 'PrimeVue.js', 'config');
}
function addUtils() {
addEntry('utils', 'Utils.js', 'utils');
}
function addApi() {
addEntry('api', 'Api.js', 'api');
}
function addServices() {
addEntry('confirmationservice', 'ConfirmationService.js', 'confirmationservice');
addEntry('confirmationeventbus', 'ConfirmationEventBus.js', 'confirmationeventbus');
addEntry('useconfirm', 'UseConfirm.js', 'useconfirm');
addEntry('toastservice', 'ToastService.js', 'toastservice');
addEntry('toasteventbus', 'ToastEventBus.js', 'toasteventbus');
addEntry('usetoast', 'UseToast.js', 'usetoast');
2021-01-18 14:35:36 +00:00
addEntry('terminalservice', 'TerminalService.js', 'terminalservice');
}
addSFC();
addDirectives();
addConfig();
addUtils();
addApi();
addServices();
2021-01-18 08:25:54 +00:00
export default entries;