From abef162a1167b583cd263464da0171210614a05d Mon Sep 17 00:00:00 2001 From: Mert Sincan Date: Wed, 1 May 2024 09:33:20 +0100 Subject: [PATCH] Refactor #5667 - For build --- nuxt-vite.config.js | 25 ++++++------------------- rollup.config.js | 28 +++++++++------------------- themes/app-theme.js | 4 +--- 3 files changed, 16 insertions(+), 41 deletions(-) diff --git a/nuxt-vite.config.js b/nuxt-vite.config.js index d014adfff..a6c2b8ff2 100644 --- a/nuxt-vite.config.js +++ b/nuxt-vite.config.js @@ -179,16 +179,10 @@ const ICON_ALIAS = { // prettier-ignore const THEME_COMPONENTS = ['accordion','autocomplete','avatar','badge','blockui','breadcrumb','button','buttongroup','card','carousel','cascadeselect','checkbox','chip','colorpicker','confirmdialog','confirmpopup','contextmenu','datatable','dataview','datepicker','dialog','divider','dock','drawer','editor','fieldset','fileupload','floatlabel','galleria','iconfield','image','inlinemessage','inplace','inputchips','inputgroup','inputnumber','inputotp','inputtext','knob','listbox','megamenu','menu','menubar','message','metergroup','multiselect','orderlist','organizationchart','paginator','panel','panelmenu','password','picklist','popover','progressbar','progressspinner','radiobutton','rating','scrollpanel','scrolltop','select','selectbutton','skeleton','slider','speeddial','splitbutton','splitter','steps','stepper','tabmenu','tabs','tabview','tag','terminal','textarea','tieredmenu','timeline','toast','togglebutton','toggleswitch','toolbar','tooltip','tree','treeselect','treetable']; -const createThemeAlias = (design, presets) => { - const baseAlias = THEME_COMPONENTS.reduce((acc, name) => { - acc[`primevue/themes/${design}/base/${name}`] = path.resolve(__dirname, `./components/lib/themes/${design}/base/${name}/index.js`); - - return acc; - }, {}); - +const createThemeAlias = (presets) => { const presetAlias = presets?.reduce((p_acc, p_name) => { const p_alias = THEME_COMPONENTS.reduce((acc, name) => { - acc[`primevue/themes/${design}/presets/${p_name}/${name}`] = path.resolve(__dirname, `./components/lib/themes/${design}/presets/${p_name}/${name}/index.js`); + acc[`primevue/themes/${p_name}/${name}`] = path.resolve(__dirname, `./components/lib/themes/${p_name}/${name}/index.js`); return acc; }, {}); @@ -198,23 +192,16 @@ const createThemeAlias = (design, presets) => { return p_acc; }, {}); - const otherAlias = presets?.reduce((p_acc, p_name) => { + const mainAlias = presets?.reduce((p_acc, p_name) => { p_acc = { ...p_acc, - [`primevue/themes/${design}/presets/${p_name}`]: path.resolve(__dirname, `./components/lib/themes/${design}/presets/${p_name}/index.js`), - [`primevue/themes/${design}/${p_name}`]: path.resolve(__dirname, `./components/lib/themes/${design}/${p_name}/index.js`) + [`primevue/themes/${p_name}`]: path.resolve(__dirname, `./components/lib/themes/${p_name}/index.js`) }; return p_acc; }, {}); - const coreAlias = { - [`primevue/themes/${design}/base/global`]: path.resolve(__dirname, `./components/lib/themes/${design}/base/global/index.js`), - [`primevue/themes/${design}/base`]: path.resolve(__dirname, `./components/lib/themes/${design}/base/index.js`), - [`primevue/themes/${design}`]: path.resolve(__dirname, `./components/lib/themes/${design}/index.js`) - }; - - return { ...baseAlias, ...presetAlias, ...otherAlias, ...coreAlias }; + return { ...presetAlias, ...mainAlias }; }; const THEME_ALIAS = { @@ -223,7 +210,7 @@ const THEME_ALIAS = { 'primevue/themes/service': path.resolve(__dirname, './components/lib/themes/service/index.js'), 'primevue/themes/helpers': path.resolve(__dirname, './components/lib/themes/helpers/index.js'), 'primevue/themes/actions': path.resolve(__dirname, './components/lib/themes/actions/index.js'), - ...createThemeAlias('primeone', ['aura']), + ...createThemeAlias(['aura']), 'primevue/themes': path.resolve(__dirname, './components/lib/themes/index.js') }; diff --git a/rollup.config.js b/rollup.config.js index d404b0953..b64f9d2f3 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -190,16 +190,10 @@ const CORE_STYLE_DEPENDENCIES = { // prettier-ignore const THEME_COMPONENTS = ['accordion','autocomplete','avatar','badge','blockui','breadcrumb','button','buttongroup','card','carousel','cascadeselect','checkbox','chip','colorpicker','confirmdialog','confirmpopup','contextmenu','datatable','dataview','datepicker','dialog','divider','dock','drawer','editor','fieldset','fileupload','floatlabel','galleria','iconfield','image','inlinemessage','inplace','inputchips','inputgroup','inputnumber','inputotp','toggleswitch','inputtext','knob','listbox','megamenu','menu','menubar','message','metergroup','multiselect','orderlist','organizationchart','overlaypanel','paginator','panel','panelmenu','password','picklist','popover','progressbar','progressspinner','radiobutton','rating','scrollpanel','scrolltop','select','selectbutton','skeleton','slider','speeddial','splitbutton','splitter','steps','stepper','tabmenu', 'tab', 'tabview','tag','terminal','textarea','tieredmenu','timeline','toast','togglebutton','toggleswitch','toolbar','tooltip','tree','treeselect','treetable']; -const createThemeDependencies = (design, presets) => { - const baseDeps = THEME_COMPONENTS.reduce((acc, name) => { - acc[`primevue/themes/${design}/base/${name}`] = `primevue.themes.${design}.base.${name}`; - - return acc; - }, {}); - +const createThemeDependencies = (presets) => { const presetDeps = presets?.reduce((p_acc, p_name) => { const p_alias = THEME_COMPONENTS.reduce((acc, name) => { - acc[`primevue/themes/${design}/presets/${p_name}/${name}`] = `primevue.themes.${design}.presets.${p_name}.${name}`; + acc[`primevue/themes/${p_name}/${name}`] = `primevue.themes.${p_name}.${name}`; return acc; }, {}); @@ -209,32 +203,25 @@ const createThemeDependencies = (design, presets) => { return p_acc; }, {}); - const otherDeps = presets?.reduce((p_acc, p_name) => { + const mainDeps = presets?.reduce((p_acc, p_name) => { p_acc = { ...p_acc, - [`primevue/themes/${design}/presets/${p_name}`]: `primevue.themes.${design}.presets.${p_name}`, - [`primevue/themes/${design}/${p_name}`]: `primevue.themes.${design}.${p_name}` + [`primevue/themes/${p_name}`]: `primevue.themes.${p_name}` }; return p_acc; }, {}); - const coreDeps = { - [`primevue/themes/${design}/base/global`]: `primevue.themes.${design}.base.global`, - [`primevue/themes/${design}/base`]: `primevue.themes.${design}.base`, - [`primevue/themes/${design}`]: `primevue.themes.${design}` - }; - - return { ...baseDeps, ...presetDeps, ...otherDeps, ...coreDeps }; + return { ...presetDeps, ...mainDeps }; }; const CORE_THEME_DEPENDENCIES = { - ...createThemeDependencies('primeone', ['aura']), 'primevue/themes/actions': 'primevue.themes.actions', 'primevue/themes/config': 'primevue.themes.config', 'primevue/themes/helpers': 'primevue.themes.helpers', 'primevue/themes/service': 'primevue.themes.service', 'primevue/themes/utils': 'primevue.themes.utils', + ...createThemeDependencies(['aura']), 'primevue/themes': 'primevue.themes' }; @@ -596,6 +583,9 @@ function addPackageJson() { "tags": "./vetur-tags.json", "attributes": "./vetur-attributes.json" }, + "sideEffects": [ + "*.vue" + ], "peerDependencies": { "vue": "^3.0.0" } diff --git a/themes/app-theme.js b/themes/app-theme.js index 3a1992f32..2ee7f2841 100644 --- a/themes/app-theme.js +++ b/themes/app-theme.js @@ -1,6 +1,5 @@ import { definePreset } from 'primevue/themes'; -import PrimeOne from 'primevue/themes/primeone'; -import Aura from 'primevue/themes/primeone/aura'; +import Aura from 'primevue/themes/aura'; const Noir = definePreset(Aura, { semantic: { @@ -51,7 +50,6 @@ const Noir = definePreset(Aura, { }); export default { - base: PrimeOne, preset: Noir, options: { darkModeSelector: '.p-dark'