Skip to content

Commit

Permalink
fix: allow serving files from cwd node_modules
Browse files Browse the repository at this point in the history
  • Loading branch information
KaiVandivier committed Aug 15, 2024
1 parent 71d1f67 commit 0233949
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions cli/config/makeViteConfig.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import react from '@vitejs/plugin-react'
import { defineConfig, transformWithEsbuild } from 'vite'
import {
defineConfig,
searchForWorkspaceRoot,
transformWithEsbuild,
} from 'vite'
import dynamicImport from 'vite-plugin-dynamic-import'

// This file is used to create config to use with the Vite Node API
Expand Down Expand Up @@ -125,7 +129,17 @@ export default ({ paths, config, env, host }) => {
// Static replacement of vars at build time
define: getDefineOptions(env),

server: { host },
server: {
host,
// By default, Vite allows serving files from a workspace root or
// falls back to the app root. Since we run the app in .d2/shell/,
// if the app is not in a workspace, files in cwd/node_modules can
// be out of reach (like fonts, which don't get bundled).
// Start the workspace search from cwd so it falls back to that
// when not in a workspace; then fonts in node_modules are usable
// https://vitejs.dev/config/server-options.html#server-fs-allow
fs: { allow: [searchForWorkspaceRoot(process.cwd())] },
},

build: {
outDir: 'build',
Expand Down

0 comments on commit 0233949

Please sign in to comment.