File tree 2 files changed +17
-10
lines changed
2 files changed +17
-10
lines changed Original file line number Diff line number Diff line change @@ -5,9 +5,6 @@ import glob from "glob";
5
5
import { build } from "vite" ;
6
6
7
7
const __dirname = path . dirname ( fileURLToPath ( import . meta. url ) ) ;
8
- const pj = JSON . parse (
9
- fs . readFileSync ( path . join ( __dirname , "package.json" ) , "utf-8" )
10
- ) ;
11
8
12
9
const files = glob . sync ( "src/api/**/*.ts" ) . map ( ( file : string ) => ( {
13
10
entry : `./${ file } ` ,
@@ -17,9 +14,14 @@ const files = glob.sync("src/api/**/*.ts").map((file: string) => ({
17
14
files . forEach ( async ( file : { entry : string ; distFileName : string } ) => {
18
15
await build ( {
19
16
ssr : {
20
- noExternal : Object . keys ( pj . dependencies || { } ) . concat (
21
- Object . keys ( pj . devDependencies || { } )
22
- ) ,
17
+ noExternal : fs
18
+ . readdirSync ( path . join ( __dirname , "node_modules" ) , {
19
+ withFileTypes : true ,
20
+ } )
21
+ . filter (
22
+ ( dirent ) => dirent . isDirectory ( ) && ! dirent . name . startsWith ( "." )
23
+ )
24
+ . map ( ( dirent ) => new RegExp ( dirent . name ) ) ,
23
25
} ,
24
26
configFile : false ,
25
27
resolve : {
Original file line number Diff line number Diff line change 1
1
import { defineConfig } from "vite" ;
2
2
import { viteStaticCopy } from "vite-plugin-static-copy" ;
3
+ import { fileURLToPath } from "node:url" ;
3
4
import path from "node:path" ;
5
+ import fs from "node:fs" ;
4
6
import react from "@vitejs/plugin-react" ;
5
- import pj from "./package.json" ;
6
7
7
8
process . env . NODE_ENV = "production" ;
9
+ const __dirname = path . dirname ( fileURLToPath ( import . meta. url ) ) ;
8
10
9
11
// https://vitejs.dev/config/
10
12
export default defineConfig ( {
11
13
ssr : {
12
- noExternal : Object . keys ( pj . dependencies || { } ) . concat (
13
- Object . keys ( pj . devDependencies || { } )
14
- ) ,
14
+ noExternal : fs
15
+ . readdirSync ( path . join ( __dirname , "node_modules" ) , {
16
+ withFileTypes : true ,
17
+ } )
18
+ . filter ( ( dirent ) => dirent . isDirectory ( ) && ! dirent . name . startsWith ( "." ) )
19
+ . map ( ( dirent ) => new RegExp ( dirent . name ) ) ,
15
20
} ,
16
21
resolve : {
17
22
alias : [
You can’t perform that action at this time.
0 commit comments