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-10-05 10:08:36 +00:00
|
|
|
let core = {};
|
|
|
|
|
2021-10-04 20:24:12 +00:00
|
|
|
let coreDependencies = {
|
2021-01-18 14:35:36 +00:00
|
|
|
'primevue/utils': 'primevue.utils',
|
2021-10-05 10:08:36 +00:00
|
|
|
'primevue/api': 'primevue.api',
|
|
|
|
'primevue/config': 'primevue.config',
|
2021-10-04 20:24:12 +00:00
|
|
|
'primevue/ripple': 'primevue.ripple',
|
2022-06-01 06:36:32 +00:00
|
|
|
'primevue/portal': 'primevue.portal',
|
2022-01-18 08:06:10 +00:00
|
|
|
'primevue/tooltip': 'primevue.tooltip',
|
2021-10-05 10:08:36 +00:00
|
|
|
'primevue/virtualscroller': 'primevue.virtualscroller',
|
2021-01-18 14:35:36 +00:00
|
|
|
'primevue/confirmationeventbus': 'primevue.confirmationeventbus',
|
|
|
|
'primevue/toasteventbus': 'primevue.toasteventbus',
|
2021-03-03 10:30:19 +00:00
|
|
|
'primevue/overlayeventbus': 'primevue.overlayeventbus',
|
2022-06-14 08:11:34 +00:00
|
|
|
'primevue/dynamicdialogeventbus': 'primevue.dynamicdialogeventbus',
|
2021-10-04 20:24:12 +00:00
|
|
|
'primevue/terminalservice': 'primevue.terminalservice',
|
2021-01-18 14:35:36 +00:00
|
|
|
'primevue/useconfirm': 'primevue.useconfirm',
|
|
|
|
'primevue/usetoast': 'primevue.usetoast',
|
2022-06-14 08:11:34 +00:00
|
|
|
'primevue/usedialog': 'primevue.usedialog',
|
2021-10-04 20:24:12 +00:00
|
|
|
'primevue/button': 'primevue.button',
|
|
|
|
'primevue/inputtext': 'primevue.inputtext',
|
2021-10-05 10:08:36 +00:00
|
|
|
'primevue/inputnumber': 'primevue.inputnumber',
|
2021-01-18 14:35:36 +00:00
|
|
|
'primevue/message': 'primevue.message',
|
2021-10-05 10:08:36 +00:00
|
|
|
'primevue/progressbar': 'primevue.progressbar',
|
2021-01-18 14:35:36 +00:00
|
|
|
'primevue/dropdown': 'primevue.dropdown',
|
2021-10-05 10:08:36 +00:00
|
|
|
'primevue/dialog': 'primevue.dialog',
|
|
|
|
'primevue/paginator': 'primevue.paginator',
|
2021-04-09 12:04:11 +00:00
|
|
|
'primevue/tree': 'primevue.tree',
|
2021-10-05 10:08:36 +00:00
|
|
|
'primevue/menu': 'primevue.menu',
|
|
|
|
'primevue/tieredmenu': 'primevue.tieredmenu'
|
2021-10-04 20:24:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
let globalDependencies = {
|
|
|
|
'vue': 'Vue',
|
|
|
|
'@fullcalendar/core': 'FullCalendar',
|
|
|
|
...coreDependencies
|
2021-01-18 14:35:36 +00:00
|
|
|
}
|
|
|
|
|
2021-01-18 11:20:34 +00:00
|
|
|
function addEntry(folder, inFile, outFile) {
|
2021-10-04 20:24:12 +00:00
|
|
|
let useCorePlugin = Object.keys(coreDependencies).some(d => d.replace('primevue/', '') === outFile);
|
|
|
|
|
2021-01-18 11:20:34 +00:00
|
|
|
entries.push({
|
|
|
|
input: 'src/components/' + folder + '/' + inFile,
|
|
|
|
output: [
|
2021-01-18 12:21:54 +00:00
|
|
|
{
|
2021-01-18 14:39:05 +00:00
|
|
|
format: 'cjs',
|
|
|
|
file: 'dist/' + folder + '/' + outFile + '.cjs.js',
|
2021-01-18 12:21:54 +00:00
|
|
|
},
|
2021-01-18 11:20:34 +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(),
|
2021-10-04 20:24:12 +00:00
|
|
|
postcss(),
|
|
|
|
useCorePlugin && corePlugin()
|
2021-01-18 12:21:54 +00:00
|
|
|
]
|
|
|
|
});
|
|
|
|
|
2021-01-18 14:39:05 +00:00
|
|
|
entries.push({
|
2021-01-18 12:21:54 +00:00
|
|
|
input: 'src/components/' + folder + '/' + inFile,
|
|
|
|
output: [
|
2021-01-18 11:20:34 +00:00
|
|
|
{
|
2021-01-18 14:39:05 +00:00
|
|
|
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-02-10 20:12:05 +00:00
|
|
|
name: 'primevue.' + folder,
|
2021-01-18 14:39:05 +00:00
|
|
|
file: 'dist/' + folder + '/' + outFile + '.min.js',
|
|
|
|
globals: globalDependencies
|
2021-01-18 11:20:34 +00:00
|
|
|
}
|
|
|
|
],
|
|
|
|
plugins: [
|
|
|
|
vue(),
|
2021-01-18 12:21:54 +00:00
|
|
|
postcss(),
|
2021-10-04 20:24:12 +00:00
|
|
|
terser(),
|
|
|
|
useCorePlugin && corePlugin()
|
2021-01-18 11:20:34 +00:00
|
|
|
]
|
2021-01-18 14:39:05 +00:00
|
|
|
});
|
2021-01-18 11:20:34 +00:00
|
|
|
}
|
|
|
|
|
2021-10-04 20:24:12 +00:00
|
|
|
function corePlugin() {
|
|
|
|
return {
|
|
|
|
name: 'corePlugin',
|
|
|
|
generateBundle(outputOptions, bundle) {
|
|
|
|
if (outputOptions.format === 'iife') {
|
|
|
|
Object.keys(bundle).forEach(id => {
|
|
|
|
const chunk = bundle[id];
|
2021-10-05 10:08:36 +00:00
|
|
|
const name = id.replace('.min.js', '').replace('.js', '');
|
2021-10-04 20:24:12 +00:00
|
|
|
const filePath = `./dist/core/core${id.indexOf('.min.js') > 0 ? '.min.js': '.js'}`;
|
|
|
|
|
2021-10-05 10:08:36 +00:00
|
|
|
core[filePath] ? (core[filePath][name] = chunk.code) : (core[filePath] = { [`${name}`]: chunk.code });
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
function addCore() {
|
|
|
|
const lastEntry = entries[entries.length - 1];
|
|
|
|
|
|
|
|
lastEntry.plugins = [
|
|
|
|
...lastEntry.plugins,
|
|
|
|
{
|
|
|
|
name: 'coreMergePlugin',
|
2021-10-06 13:14:44 +00:00
|
|
|
generateBundle() {
|
2021-10-05 10:08:36 +00:00
|
|
|
Object.entries(core).forEach(([filePath, value]) => {
|
|
|
|
const code = Object.keys(coreDependencies).reduce((val, d) => {
|
|
|
|
const name = d.replace('primevue/', '');
|
|
|
|
val += value[name] + '\n';
|
|
|
|
|
|
|
|
return val;
|
|
|
|
}, '');
|
|
|
|
|
|
|
|
fs.outputFile(path.resolve(__dirname, filePath), code, {}, function(err) {
|
2021-10-04 20:24:12 +00:00
|
|
|
if (err) {
|
|
|
|
return console.error(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2021-10-05 10:08:36 +00:00
|
|
|
]
|
2021-10-04 20:24:12 +00:00
|
|
|
}
|
|
|
|
|
2021-01-18 11:20:34 +00:00
|
|
|
function addSFC() {
|
2021-12-01 21:15:31 +00:00
|
|
|
fs.readdirSync(path.resolve(__dirname, './src/components/'), { withFileTypes: true })
|
|
|
|
.filter(dir => dir.isDirectory())
|
|
|
|
.forEach(({ name: folderName }) => {
|
|
|
|
fs.readdirSync(path.resolve(__dirname, './src/components/' + folderName)).forEach(file => {
|
|
|
|
let name = file.split(/(.vue)$|(.js)$/)[0].toLowerCase();
|
|
|
|
if (/\.vue$/.test(file) && (name === folderName)) {
|
|
|
|
addEntry(folderName, file, name);
|
|
|
|
}
|
|
|
|
});
|
2021-01-18 11:20:34 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function addDirectives() {
|
|
|
|
addEntry('badgedirective', 'BadgeDirective.js', 'badgedirective');
|
|
|
|
addEntry('ripple', 'Ripple.js', 'ripple');
|
|
|
|
addEntry('tooltip', 'Tooltip.js', 'tooltip');
|
2021-08-04 10:01:32 +00:00
|
|
|
addEntry('styleclass', 'StyleClass.js', 'styleclass');
|
2021-01-18 11:20:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function addConfig() {
|
|
|
|
addEntry('config', 'PrimeVue.js', 'config');
|
|
|
|
}
|
|
|
|
|
|
|
|
function addUtils() {
|
|
|
|
addEntry('utils', 'Utils.js', 'utils');
|
|
|
|
}
|
|
|
|
|
2021-02-06 09:26:12 +00:00
|
|
|
function addApi() {
|
|
|
|
addEntry('api', 'Api.js', 'api');
|
|
|
|
}
|
|
|
|
|
2021-01-18 11:20:34 +00:00
|
|
|
function addServices() {
|
|
|
|
addEntry('confirmationservice', 'ConfirmationService.js', 'confirmationservice');
|
|
|
|
addEntry('confirmationeventbus', 'ConfirmationEventBus.js', 'confirmationeventbus');
|
2021-01-18 15:16:32 +00:00
|
|
|
addEntry('useconfirm', 'UseConfirm.js', 'useconfirm');
|
2021-01-18 11:20:34 +00:00
|
|
|
addEntry('toastservice', 'ToastService.js', 'toastservice');
|
|
|
|
addEntry('toasteventbus', 'ToastEventBus.js', 'toasteventbus');
|
2021-03-03 10:30:19 +00:00
|
|
|
addEntry('overlayeventbus', 'OverlayEventBus.js', 'overlayeventbus');
|
2021-01-18 15:16:32 +00:00
|
|
|
addEntry('usetoast', 'UseToast.js', 'usetoast');
|
2021-01-18 14:35:36 +00:00
|
|
|
addEntry('terminalservice', 'TerminalService.js', 'terminalservice');
|
2022-06-14 08:11:34 +00:00
|
|
|
addEntry('usedialog', 'UseDialog.js', 'usedialog');
|
|
|
|
addEntry('dialogservice', 'DialogService.js', 'dialogservice');
|
|
|
|
addEntry('dynamicdialogeventbus', 'DynamicDialogEventBus.js', 'dynamicdialogeventbus');
|
2021-01-18 11:20:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
addUtils();
|
2021-02-06 09:26:12 +00:00
|
|
|
addApi();
|
2021-10-04 20:24:12 +00:00
|
|
|
addConfig();
|
|
|
|
addDirectives();
|
2021-01-18 11:20:34 +00:00
|
|
|
addServices();
|
2021-10-04 20:24:12 +00:00
|
|
|
addSFC();
|
2021-10-05 10:08:36 +00:00
|
|
|
addCore();
|
2021-01-18 08:25:54 +00:00
|
|
|
|
2021-08-13 14:29:39 +00:00
|
|
|
export default entries;
|