Skip to content
This repository has been archived by the owner on Feb 10, 2024. It is now read-only.

Commit

Permalink
allowing extra vite config
Browse files Browse the repository at this point in the history
  • Loading branch information
sudomf committed Nov 10, 2022
1 parent a8a31b5 commit 75c9641
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 28 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "remix-vite",
"version": "0.2.1",
"version": "0.2.2",
"description": "Static file serving and directory listing",
"keywords": [
"remix",
Expand Down
52 changes: 25 additions & 27 deletions src/vite.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createServer } from 'vite';
import { createServer, mergeConfig } from 'vite';
import vitePluginReact from '@vitejs/plugin-react';
import tsconfigPaths from 'vite-tsconfig-paths';
import { getHmrFixPlugin } from './plugins/hmr-fix';
Expand All @@ -7,13 +7,9 @@ import { getRemixPlugin } from './plugins/remix';
import { getTransformPlugin } from './plugins/transform';
import { SERVER_ENTRY_ID } from './constants';
import { checkVersion } from './utils/version';
import type { ViteDevServer, ServerOptions } from 'vite';
import type { ViteDevServer, UserConfig } from 'vite';
import type { ServerBuild } from '@remix-run/server-runtime';

export interface RemixViteServerOptions {
serverOptions?: ServerOptions;
}

/**
* Get Remix build
*/
Expand All @@ -28,9 +24,7 @@ export const getRemixViteBuild = async (viteDevServer: ViteDevServer) => {
/**
* Create remix-vite dev server
*/
export const createRemixViteDevServer = async (
options?: RemixViteServerOptions,
) => {
export const createRemixViteDevServer = async (config?: UserConfig) => {
await checkVersion();

const remixPlugin = await getRemixPlugin();
Expand All @@ -41,23 +35,27 @@ export const createRemixViteDevServer = async (
// Create Vite server in middleware mode and configure the app type as
// 'custom', disabling Vite's own HTML serving logic so parent server
// can take control
return createServer({
server: {
fs: {
strict: false,
return createServer(
mergeConfig(
{
server: {
fs: {
strict: false,
},
cors: true,
middlewareMode: true,
},
plugins: [
tsconfigPaths(),
remixInject,
remixPlugin,
remixTransformPlugin,
vitePluginReact(),
remixHmrFix,
],
appType: 'custom',
},
cors: true,
...options?.serverOptions,
middlewareMode: true,
},
plugins: [
tsconfigPaths(),
remixInject,
remixPlugin,
remixTransformPlugin,
vitePluginReact(),
remixHmrFix,
],
appType: 'custom',
});
config || {},
),
);
};

0 comments on commit 75c9641

Please sign in to comment.