Added hot dev mode
parent
4795c2382b
commit
02094f31ae
|
@ -12,6 +12,14 @@ const alias = {
|
||||||
'@primevue/icons': path.resolve(__dirname, '../../packages/icons/src')
|
'@primevue/icons': path.resolve(__dirname, '../../packages/icons/src')
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let PROCESS_ENV = {};
|
||||||
|
|
||||||
|
try {
|
||||||
|
PROCESS_ENV = process?.env || {};
|
||||||
|
} catch {
|
||||||
|
// NOOP
|
||||||
|
}
|
||||||
|
|
||||||
// https://nuxt.com/docs/api/configuration/nuxt-config
|
// https://nuxt.com/docs/api/configuration/nuxt-config
|
||||||
export default defineNuxtConfig({
|
export default defineNuxtConfig({
|
||||||
typescript: false,
|
typescript: false,
|
||||||
|
@ -35,10 +43,17 @@ export default defineNuxtConfig({
|
||||||
'/accessibility': { redirect: { to: '/guides/accessibility', statusCode: 301 } },
|
'/accessibility': { redirect: { to: '/guides/accessibility', statusCode: 301 } },
|
||||||
'/installation': { redirect: { to: '/vite', statusCode: 301 } }
|
'/installation': { redirect: { to: '/vite', statusCode: 301 } }
|
||||||
},
|
},
|
||||||
primevue: {
|
primevue:
|
||||||
autoImport: true, // When enabled, the module automatically imports PrimeVue components and directives used throughout the application.
|
PROCESS_ENV.DEV_ENV === 'hot'
|
||||||
importTheme: { from: '@/themes/app-theme.js' }
|
? {
|
||||||
},
|
usePrimeVue: false,
|
||||||
|
autoImport: true,
|
||||||
|
loadStyles: false
|
||||||
|
}
|
||||||
|
: {
|
||||||
|
autoImport: true, // When enabled, the module automatically imports PrimeVue components and directives used throughout the application.
|
||||||
|
importTheme: { from: '@/themes/app-theme.js' }
|
||||||
|
},
|
||||||
app: {
|
app: {
|
||||||
baseURL: baseUrl,
|
baseURL: baseUrl,
|
||||||
head: {
|
head: {
|
||||||
|
@ -79,7 +94,8 @@ export default defineNuxtConfig({
|
||||||
},
|
},
|
||||||
runtimeConfig: {
|
runtimeConfig: {
|
||||||
public: {
|
public: {
|
||||||
contextPath: baseUrl
|
contextPath: baseUrl,
|
||||||
|
DEV_ENV: PROCESS_ENV.DEV_ENV
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
gtag: {
|
gtag: {
|
||||||
|
|
|
@ -16,6 +16,15 @@ const $appState = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export default defineNuxtPlugin((nuxtApp) => {
|
export default defineNuxtPlugin(async (nuxtApp) => {
|
||||||
|
const runtimeConfig = useRuntimeConfig();
|
||||||
|
|
||||||
nuxtApp.vueApp.use($appState);
|
nuxtApp.vueApp.use($appState);
|
||||||
|
|
||||||
|
if (runtimeConfig.public.DEV_ENV === 'hot') {
|
||||||
|
const { default: PrimeVue } = await import('primevue/config');
|
||||||
|
const { default: Noir } = await import('@/themes/app-theme');
|
||||||
|
|
||||||
|
nuxtApp.vueApp.use(PrimeVue, { theme: Noir });
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -27,9 +27,10 @@
|
||||||
"build:lib": "pnpm --filter primevue build",
|
"build:lib": "pnpm --filter primevue build",
|
||||||
"build:themes": "pnpm --filter themes build",
|
"build:themes": "pnpm --filter themes build",
|
||||||
"build:icons": "pnpm --filter icons build",
|
"build:icons": "pnpm --filter icons build",
|
||||||
"build:showcase": "pnpm --filter showcase build:prebuild",
|
"build:showcase": "pnpm --filter showcase build",
|
||||||
"build:apidoc": "pnpm --filter themes build:tokens && pnpm --filter showcase build:apidoc",
|
"build:apidoc": "pnpm --filter themes build:tokens && pnpm --filter showcase build:apidoc",
|
||||||
"dev": "pnpm --filter showcase dev",
|
"dev": "pnpm --filter showcase dev",
|
||||||
|
"hot:dev": "DEV_ENV=hot pnpm --filter showcase dev",
|
||||||
"module:dev": "pnpm --filter @primevue/nuxt-module dev",
|
"module:dev": "pnpm --filter @primevue/nuxt-module dev",
|
||||||
"security:check": "pnpm audit --prod --audit-level high",
|
"security:check": "pnpm audit --prod --audit-level high",
|
||||||
"format": "prettier --write \"**/*.{vue,js,mjs,ts,d.ts}\" --cache",
|
"format": "prettier --write \"**/*.{vue,js,mjs,ts,d.ts}\" --cache",
|
||||||
|
|
|
@ -21,6 +21,7 @@ export default defineNuxtModule<ModuleOptions>({
|
||||||
//cssLayerOrder: undefined,
|
//cssLayerOrder: undefined,
|
||||||
importPT: undefined,
|
importPT: undefined,
|
||||||
importTheme: undefined,
|
importTheme: undefined,
|
||||||
|
loadStyles: true,
|
||||||
options: {},
|
options: {},
|
||||||
components: {
|
components: {
|
||||||
prefix: '',
|
prefix: '',
|
||||||
|
@ -47,7 +48,7 @@ export default defineNuxtModule<ModuleOptions>({
|
||||||
|
|
||||||
const resolver = createResolver(import.meta.url);
|
const resolver = createResolver(import.meta.url);
|
||||||
const registered = register(moduleOptions);
|
const registered = register(moduleOptions);
|
||||||
const { autoImport, importPT, importTheme, options } = moduleOptions;
|
const { autoImport, importPT, importTheme, options, loadStyles } = moduleOptions;
|
||||||
const hasTheme = (importTheme || options?.theme) && !options?.unstyled;
|
const hasTheme = (importTheme || options?.theme) && !options?.unstyled;
|
||||||
|
|
||||||
nuxt.options.runtimeConfig.public.primevue = {
|
nuxt.options.runtimeConfig.public.primevue = {
|
||||||
|
@ -84,6 +85,8 @@ export default defineNuxtModule<ModuleOptions>({
|
||||||
}
|
}
|
||||||
|
|
||||||
const styleContent = () => {
|
const styleContent = () => {
|
||||||
|
if (!loadStyles) return `export const styles = [], stylesToTop = [], themes = [];`;
|
||||||
|
|
||||||
const uniqueRegisteredStyles = Array.from(new Map(registeredStyles?.map((m: MetaType) => [m.name, m])).values());
|
const uniqueRegisteredStyles = Array.from(new Map(registeredStyles?.map((m: MetaType) => [m.name, m])).values());
|
||||||
|
|
||||||
return `
|
return `
|
||||||
|
@ -102,11 +105,11 @@ const { options = {} } = config;
|
||||||
|
|
||||||
const stylesToTop = [${registered.injectStylesAsStringToTop.join('')}].join('');
|
const stylesToTop = [${registered.injectStylesAsStringToTop.join('')}].join('');
|
||||||
const styleProps = {
|
const styleProps = {
|
||||||
${options?.csp?.nonce ? `nonce: ${options?.csp?.nonce}` : ''}
|
${options?.csp?.nonce ? `nonce: ${options?.csp?.nonce}` : ''}
|
||||||
}
|
}
|
||||||
const styles = [
|
const styles = [
|
||||||
${registered.injectStylesAsString.join('')},
|
${registered.injectStylesAsString.join('')},
|
||||||
${uniqueRegisteredStyles?.map((item: MetaType) => `${item.as} && ${item.as}.getStyleSheet ? ${item.as}.getStyleSheet(undefined, styleProps) : ''`).join(',')}
|
${uniqueRegisteredStyles?.map((item: MetaType) => `${item.as} && ${item.as}.getStyleSheet ? ${item.as}.getStyleSheet(undefined, styleProps) : ''`).join(',')}
|
||||||
].join('');
|
].join('');
|
||||||
|
|
||||||
${hasTheme ? `Theme.setTheme(${importTheme?.as} || options?.theme)` : ''}
|
${hasTheme ? `Theme.setTheme(${importTheme?.as} || options?.theme)` : ''}
|
||||||
|
|
|
@ -14,6 +14,7 @@ export interface ModuleOptions {
|
||||||
/*cssLayerOrder?: string;*/
|
/*cssLayerOrder?: string;*/
|
||||||
importPT?: ImportOptions;
|
importPT?: ImportOptions;
|
||||||
importTheme?: ImportOptions;
|
importTheme?: ImportOptions;
|
||||||
|
loadStyles?: boolean;
|
||||||
options?: PrimeVueOptions;
|
options?: PrimeVueOptions;
|
||||||
components?: ConstructsType;
|
components?: ConstructsType;
|
||||||
directives?: ConstructsType;
|
directives?: ConstructsType;
|
||||||
|
|
Loading…
Reference in New Issue