2022-09-10 14:15:16 +00:00
|
|
|
import postcss from 'rollup-plugin-postcss';
|
|
|
|
import { terser } from 'rollup-plugin-terser';
|
|
|
|
import vue from 'rollup-plugin-vue';
|
|
|
|
|
|
|
|
const fs = require('fs-extra');
|
|
|
|
const path = require('path');
|
|
|
|
|
|
|
|
let entries = [];
|
|
|
|
|
|
|
|
let core = {};
|
|
|
|
|
2023-04-01 01:15:53 +00:00
|
|
|
let coreIconDependencies = {
|
|
|
|
'primevue/baseicon': 'primevue.baseicon',
|
|
|
|
'primevue/icon/angledoubledown': 'primevue.icon.angledoubledown',
|
|
|
|
'primevue/icon/angledoubleleft': 'primevue.icon.angledoubleleft',
|
|
|
|
'primevue/icon/angledoubleright': 'primevue.icon.angledoubleright',
|
|
|
|
'primevue/icon/angledoubleup': 'primevue.icon.angledoubleup',
|
|
|
|
'primevue/icon/angledown': 'primevue.icon.angledown',
|
|
|
|
'primevue/icon/angleleft': 'primevue.icon.angleleft',
|
|
|
|
'primevue/icon/angleright': 'primevue.icon.angleright',
|
|
|
|
'primevue/icon/angleup': 'primevue.icon.angleup',
|
|
|
|
'primevue/icon/arrowdown': 'primevue.icon.arrowdown',
|
|
|
|
'primevue/icon/arrowup': 'primevue.icon.arrowup',
|
|
|
|
'primevue/icon/ban': 'primevue.icon.ban',
|
|
|
|
'primevue/icon/bars': 'primevue.icon.bars',
|
|
|
|
'primevue/icon/calendar': 'primevue.icon.calendar',
|
|
|
|
'primevue/icon/check': 'primevue.icon.check',
|
|
|
|
'primevue/icon/chevrondown': 'primevue.icon.chevrondown',
|
|
|
|
'primevue/icon/chevronleft': 'primevue.icon.chevronleft',
|
|
|
|
'primevue/icon/chevronright': 'primevue.icon.chevronright',
|
|
|
|
'primevue/icon/chevronup': 'primevue.icon.chevronup',
|
|
|
|
'primevue/icon/exclamationtriangle': 'primevue.icon.exclamationtriangle',
|
|
|
|
'primevue/icon/eye': 'primevue.icon.eye',
|
|
|
|
'primevue/icon/eyeslash': 'primevue.icon.eyeslash',
|
|
|
|
'primevue/icon/filter': 'primevue.icon.filter',
|
|
|
|
'primevue/icon/filterslash': 'primevue.icon.filterslash',
|
|
|
|
'primevue/icon/infocircle': 'primevue.icon.infocircle',
|
|
|
|
'primevue/icon/minus': 'primevue.icon.minus',
|
|
|
|
'primevue/icon/pencil': 'primevue.icon.pencil',
|
|
|
|
'primevue/icon/plus': 'primevue.icon.plus',
|
|
|
|
'primevue/icon/refresh': 'primevue.icon.refresh',
|
|
|
|
'primevue/icon/search': 'primevue.icon.search',
|
|
|
|
'primevue/icon/searchminus': 'primevue.icon.searchminus',
|
|
|
|
'primevue/icon/searchplus': 'primevue.icon.searchplus',
|
|
|
|
'primevue/icon/sortalt': 'primevue.icon.sortalt',
|
|
|
|
'primevue/icon/sortamountdown': 'primevue.icon.sortamountdown',
|
|
|
|
'primevue/icon/sortamountupalt': 'primevue.icon.sortamountupalt',
|
|
|
|
'primevue/icon/spinner': 'primevue.icon.spinner',
|
|
|
|
'primevue/icon/star': 'primevue.icon.star',
|
|
|
|
'primevue/icon/starfill': 'primevue.icon.starfill',
|
|
|
|
'primevue/icon/thlarge': 'primevue.icon.thlarge',
|
|
|
|
'primevue/icon/times': 'primevue.icon.times',
|
|
|
|
'primevue/icon/timescircle': 'primevue.icon.timescircle',
|
|
|
|
'primevue/icon/trash': 'primevue.icon.trash',
|
|
|
|
'primevue/icon/undo': 'primevue.icon.undo',
|
|
|
|
'primevue/icon/upload': 'primevue.icon.upload',
|
|
|
|
'primevue/icon/windowmaximize': 'primevue.icon.windowmaximize',
|
|
|
|
'primevue/icon/windowminimize': 'primevue.icon.windowminimize'
|
|
|
|
};
|
|
|
|
|
2022-09-10 14:15:16 +00:00
|
|
|
let coreDependencies = {
|
|
|
|
'primevue/utils': 'primevue.utils',
|
|
|
|
'primevue/api': 'primevue.api',
|
|
|
|
'primevue/config': 'primevue.config',
|
|
|
|
'primevue/ripple': 'primevue.ripple',
|
|
|
|
'primevue/portal': 'primevue.portal',
|
2023-04-01 01:15:53 +00:00
|
|
|
'primevue/basecomponent': 'primevue.basecomponent',
|
|
|
|
...coreIconDependencies,
|
2022-09-10 14:15:16 +00:00
|
|
|
'primevue/tooltip': 'primevue.tooltip',
|
2022-12-09 08:12:43 +00:00
|
|
|
'primevue/focustrap': 'primevue.focustrap',
|
2022-09-10 14:15:16 +00:00
|
|
|
'primevue/virtualscroller': 'primevue.virtualscroller',
|
|
|
|
'primevue/confirmationeventbus': 'primevue.confirmationeventbus',
|
|
|
|
'primevue/toasteventbus': 'primevue.toasteventbus',
|
|
|
|
'primevue/overlayeventbus': 'primevue.overlayeventbus',
|
|
|
|
'primevue/dynamicdialogeventbus': 'primevue.dynamicdialogeventbus',
|
|
|
|
'primevue/terminalservice': 'primevue.terminalservice',
|
|
|
|
'primevue/useconfirm': 'primevue.useconfirm',
|
|
|
|
'primevue/usetoast': 'primevue.usetoast',
|
|
|
|
'primevue/usedialog': 'primevue.usedialog',
|
|
|
|
'primevue/button': 'primevue.button',
|
|
|
|
'primevue/inputtext': 'primevue.inputtext',
|
|
|
|
'primevue/inputnumber': 'primevue.inputnumber',
|
|
|
|
'primevue/message': 'primevue.message',
|
|
|
|
'primevue/progressbar': 'primevue.progressbar',
|
|
|
|
'primevue/dropdown': 'primevue.dropdown',
|
|
|
|
'primevue/dialog': 'primevue.dialog',
|
|
|
|
'primevue/paginator': 'primevue.paginator',
|
|
|
|
'primevue/tree': 'primevue.tree',
|
|
|
|
'primevue/menu': 'primevue.menu',
|
2022-12-09 08:12:43 +00:00
|
|
|
'primevue/tieredmenu': 'primevue.tieredmenu',
|
|
|
|
'primevue/badge': 'primevue.badge'
|
2022-09-10 14:15:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
let globalDependencies = {
|
|
|
|
vue: 'Vue',
|
|
|
|
...coreDependencies
|
|
|
|
};
|
|
|
|
|
|
|
|
function addEntry(folder, inFile, outFile) {
|
2023-04-01 01:15:53 +00:00
|
|
|
let useCorePlugin = Object.keys(coreDependencies).some((d) => d.replace('primevue/', '') === folder);
|
2022-09-10 14:15:16 +00:00
|
|
|
|
|
|
|
entries.push({
|
2023-03-26 05:22:57 +00:00
|
|
|
input: 'components/lib/' + folder + '/' + inFile,
|
2022-09-10 14:15:16 +00:00
|
|
|
output: [
|
|
|
|
{
|
|
|
|
format: 'cjs',
|
|
|
|
file: 'dist/' + folder + '/' + outFile + '.cjs.js'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
format: 'esm',
|
|
|
|
file: 'dist/' + folder + '/' + outFile + '.esm.js'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
format: 'iife',
|
2023-04-01 01:15:53 +00:00
|
|
|
name: 'primevue.' + folder.replaceAll('/', '.'),
|
2022-09-10 14:15:16 +00:00
|
|
|
file: 'dist/' + folder + '/' + outFile + '.js',
|
|
|
|
globals: globalDependencies
|
|
|
|
}
|
|
|
|
],
|
|
|
|
plugins: [vue(), postcss(), useCorePlugin && corePlugin()]
|
|
|
|
});
|
|
|
|
|
|
|
|
entries.push({
|
2023-03-26 05:22:57 +00:00
|
|
|
input: 'components/lib/' + folder + '/' + inFile,
|
2022-09-10 14:15:16 +00:00
|
|
|
output: [
|
|
|
|
{
|
|
|
|
format: 'cjs',
|
|
|
|
file: 'dist/' + folder + '/' + outFile + '.cjs.min.js'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
format: 'esm',
|
|
|
|
file: 'dist/' + folder + '/' + outFile + '.esm.min.js'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
format: 'iife',
|
2023-04-01 01:15:53 +00:00
|
|
|
name: 'primevue.' + folder.replaceAll('/', '.'),
|
2022-09-10 14:15:16 +00:00
|
|
|
file: 'dist/' + folder + '/' + outFile + '.min.js',
|
|
|
|
globals: globalDependencies
|
|
|
|
}
|
|
|
|
],
|
|
|
|
plugins: [vue(), postcss(), terser(), useCorePlugin && corePlugin()]
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function corePlugin() {
|
|
|
|
return {
|
|
|
|
name: 'corePlugin',
|
|
|
|
generateBundle(outputOptions, bundle) {
|
2023-04-01 01:15:53 +00:00
|
|
|
const { name, format } = outputOptions;
|
|
|
|
|
|
|
|
if (format === 'iife') {
|
2022-09-10 14:15:16 +00:00
|
|
|
Object.keys(bundle).forEach((id) => {
|
|
|
|
const chunk = bundle[id];
|
2023-04-01 01:15:53 +00:00
|
|
|
const folderName = name.replace('primevue.', '').replaceAll('.', '/');
|
2022-09-10 14:15:16 +00:00
|
|
|
const filePath = `./dist/core/core${id.indexOf('.min.js') > 0 ? '.min.js' : '.js'}`;
|
|
|
|
|
2023-04-01 01:15:53 +00:00
|
|
|
core[filePath] ? (core[filePath][folderName] = chunk.code) : (core[filePath] = { [`${folderName}`]: chunk.code });
|
2022-09-10 14:15:16 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
function addCore() {
|
|
|
|
const lastEntry = entries[entries.length - 1];
|
|
|
|
|
|
|
|
lastEntry.plugins = [
|
|
|
|
...lastEntry.plugins,
|
|
|
|
{
|
|
|
|
name: 'coreMergePlugin',
|
|
|
|
generateBundle() {
|
|
|
|
Object.entries(core).forEach(([filePath, value]) => {
|
|
|
|
const code = Object.keys(coreDependencies).reduce((val, d) => {
|
|
|
|
const name = d.replace('primevue/', '');
|
2022-09-14 14:49:38 +00:00
|
|
|
|
2022-09-10 14:15:16 +00:00
|
|
|
val += value[name] + '\n';
|
|
|
|
|
|
|
|
return val;
|
|
|
|
}, '');
|
|
|
|
|
|
|
|
fs.outputFile(path.resolve(__dirname, filePath), code, {}, function (err) {
|
|
|
|
if (err) {
|
|
|
|
// eslint-disable-next-line no-console
|
|
|
|
return console.error(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
function addSFC() {
|
2023-03-26 05:22:57 +00:00
|
|
|
fs.readdirSync(path.resolve(__dirname, './components/lib'), { withFileTypes: true })
|
2022-09-10 14:15:16 +00:00
|
|
|
.filter((dir) => dir.isDirectory())
|
|
|
|
.forEach(({ name: folderName }) => {
|
2023-03-26 05:22:57 +00:00
|
|
|
fs.readdirSync(path.resolve(__dirname, './components/lib/' + folderName)).forEach((file) => {
|
2022-09-10 14:15:16 +00:00
|
|
|
let name = file.split(/(.vue)$|(.js)$/)[0].toLowerCase();
|
2022-12-20 12:32:32 +00:00
|
|
|
|
2022-09-10 14:15:16 +00:00
|
|
|
if (/\.vue$/.test(file) && name === folderName) {
|
|
|
|
addEntry(folderName, file, name);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-04-01 01:15:53 +00:00
|
|
|
function addIcon() {
|
|
|
|
fs.readdirSync(path.resolve(__dirname, './components/lib/icon'), { withFileTypes: true })
|
|
|
|
.filter((dir) => dir.isDirectory())
|
|
|
|
.forEach(({ name: folderName }) => {
|
|
|
|
fs.readdirSync(path.resolve(__dirname, './components/lib/icon/' + folderName)).forEach((file) => {
|
|
|
|
if (/\.vue$/.test(file)) {
|
|
|
|
addEntry('icon/' + folderName, 'index.vue', 'index');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-09-10 14:15:16 +00:00
|
|
|
function addDirectives() {
|
|
|
|
addEntry('badgedirective', 'BadgeDirective.js', 'badgedirective');
|
|
|
|
addEntry('ripple', 'Ripple.js', 'ripple');
|
|
|
|
addEntry('tooltip', 'Tooltip.js', 'tooltip');
|
2022-12-09 08:12:43 +00:00
|
|
|
addEntry('focustrap', 'FocusTrap.js', 'focustrap');
|
2022-09-10 14:15:16 +00:00
|
|
|
addEntry('styleclass', 'StyleClass.js', 'styleclass');
|
|
|
|
}
|
|
|
|
|
|
|
|
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('overlayeventbus', 'OverlayEventBus.js', 'overlayeventbus');
|
|
|
|
addEntry('usetoast', 'UseToast.js', 'usetoast');
|
|
|
|
addEntry('terminalservice', 'TerminalService.js', 'terminalservice');
|
|
|
|
addEntry('usedialog', 'UseDialog.js', 'usedialog');
|
|
|
|
addEntry('dialogservice', 'DialogService.js', 'dialogservice');
|
|
|
|
addEntry('dynamicdialogeventbus', 'DynamicDialogEventBus.js', 'dynamicdialogeventbus');
|
|
|
|
}
|
|
|
|
|
|
|
|
addUtils();
|
|
|
|
addApi();
|
|
|
|
addConfig();
|
|
|
|
addDirectives();
|
|
|
|
addServices();
|
|
|
|
addSFC();
|
2023-04-01 01:15:53 +00:00
|
|
|
addIcon();
|
2022-09-10 14:15:16 +00:00
|
|
|
addCore();
|
|
|
|
|
|
|
|
export default entries;
|