File tree Expand file tree Collapse file tree 2 files changed +62
-0
lines changed Expand file tree Collapse file tree 2 files changed +62
-0
lines changed Original file line number Diff line number Diff line change 1+ import { defineNuxtModule , useLogger , resolvePath } from 'nuxt/kit'
2+ import { build } from 'vite'
3+ import fs from 'node:fs'
4+ import { viteConfigCms } from './vite.config.cms'
5+
6+ /*
7+ * Builds sveltia cms when nuxt is being built.
8+ */
9+ export default defineNuxtModule ( {
10+ meta : {
11+ name : 'sveltia-cms' ,
12+ configKey : 'sveltiaCms' ,
13+ } ,
14+ setup ( options , nuxt ) {
15+ nuxt . hook ( 'build:before' , async ( ) => {
16+ const resolvedPath = await resolvePath ( viteConfigCms . root as string )
17+ if ( ! fs . existsSync ( resolvedPath ) ) {
18+ const logger = useLogger ( )
19+ logger . warn ( `sveltia-cms: Path "${ resolvedPath } " doesn't exist. Build was skipped.` )
20+ return
21+ }
22+ // Enable watch for development mode
23+ if ( nuxt . options . dev === true && viteConfigCms . build !== undefined ) {
24+ viteConfigCms . build . watch = { }
25+ }
26+ await build ( viteConfigCms )
27+ } )
28+ } ,
29+ } )
Original file line number Diff line number Diff line change 1+ import { defineConfig } from 'vite'
2+ import type { UserConfig } from 'vite'
3+
4+ export const viteConfigCms : UserConfig = {
5+ root : './admin' ,
6+ base : '/admin/' ,
7+ build : {
8+ outDir : '../public/admin' ,
9+ chunkSizeWarningLimit : 10000 ,
10+ emptyOutDir : true ,
11+ } ,
12+ server : {
13+ proxy : {
14+ '/preview' : {
15+ target : 'http://localhost:3000' ,
16+ changeOrigin : true ,
17+ rewrite : ( path : string ) => path . replace ( / ^ \/ p r e v i e w / , '' ) ,
18+ } ,
19+ '/_nuxt' : {
20+ target : 'http://localhost:3000' ,
21+ changeOrigin : true ,
22+ } ,
23+ '/_ipx' : {
24+ target : 'http://localhost:3000' ,
25+ changeOrigin : true ,
26+ } ,
27+ } ,
28+ } ,
29+ }
30+
31+ export default defineConfig ( ( ) : UserConfig => {
32+ return viteConfigCms
33+ } )
You can’t perform that action at this time.
0 commit comments