Skip to content

Commit

Permalink
배포 시도 vite config
Browse files Browse the repository at this point in the history
  • Loading branch information
dutexion committed Aug 6, 2024
1 parent ea571b8 commit 40cbd48
Showing 1 changed file with 12 additions and 30 deletions.
42 changes: 12 additions & 30 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,28 @@ import reactRefresh from '@vitejs/plugin-react-refresh';
import react from '@vitejs/plugin-react';
import path from 'path';
import { defineConfig } from 'vite';
import fs from 'fs';

function ignoreUseClientPlugin() {
function removeUseClientPlugin() {
return {
name: 'ignore-use-client',
name: 'remove-use-client',
transform(code, id) {
if (id.includes('node_modules/@tanstack/react-query-devtools')) {
return code.replace(/'use client';?/g, '');
if (id.includes('@tanstack/react-query') || id.includes('@tanstack/react-query-devtools')) {
return {
code: code.replace(/^['"]use client['"];?\s*$/m, ''),
map: null,
};
}
},
};
}

// https://vitejs.dev/config/
export default defineConfig({
esbuild: {
supported: {
'top-level-await': true,
},
},
optimizeDeps: {
esbuildOptions: {
define: {
global: 'globalThis',
},
plugins: [
{
name: 'ignore-use-client-directive',
setup(build) {
build.onLoad({ filter: /.*/ }, async (args) => {
if (args.path.includes('node_modules/@tanstack/react-query-devtools')) {
return {
contents: (await fs.promises.readFile(args.path, 'utf8')).replace(/'use client';?/g, ''),
};
}
});
},
},
],
},
include: ['@tanstack/react-query', '@tanstack/react-query-devtools'],
},
esbuild: {
logOverride: { 'this-is-undefined-in-esm': 'silent' },
},
server: {
port: 3002,
Expand All @@ -54,5 +36,5 @@ export default defineConfig({
build: {
outDir: 'build',
},
plugins: [react(), reactRefresh(), ignoreUseClientPlugin()],
plugins: [react(), reactRefresh(), removeUseClientPlugin()],
});

0 comments on commit 40cbd48

Please sign in to comment.