fix: fix vite config

This commit is contained in:
熊潇 2024-10-03 15:05:24 +08:00
parent cf5159d3b4
commit ff90ca3851
2 changed files with 30 additions and 23 deletions

View File

@ -1,9 +1,9 @@
console.log('tailwind.config.js') console.log('tailwind.config.js');
/** @type {import('tailwindcss').Config} */ /** @type {import('tailwindcss').Config} */
export default { export default {
darkMode: ["class"], darkMode: ['class'],
content: ['./src/**/*.{ts,tsx}'], content: ['./src/**/*.{ts,tsx}'],
plugins: [require('@tailwindcss/aspect-ratio'), require('@tailwindcss/typography')], plugins: [require('@tailwindcss/aspect-ratio'), require('@tailwindcss/typography'), require('tailwindcss-animate')],
theme: { theme: {
extend: {}, extend: {},
screen: { screen: {
@ -23,9 +23,8 @@ export default {
// => @media (min-width: 1536px) { ... } // => @media (min-width: 1536px) { ... }
'3xl': '1920px', '3xl': '1920px',
// => @media (min-width: 1920) { ... } // => @media (min-width: 1920) { ... }
'4xl': '2560px' '4xl': '2560px',
// => @media (min-width: 2560) { ... } // => @media (min-width: 2560) { ... }
} },
}, },
plugins: [require("tailwindcss-animate")] };
}

View File

@ -1,34 +1,42 @@
import { defineConfig } from 'vite' import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react' import react from '@vitejs/plugin-react';
import tailwindcss from 'tailwindcss' import tailwindcss from 'tailwindcss';
import autoprefixer from 'autoprefixer' import autoprefixer from 'autoprefixer';
import path from 'path' import path from 'path';
import nesting from 'tailwindcss/nesting' import nesting from 'tailwindcss/nesting';
// https://vitejs.dev/config/ // https://vitejs.dev/config/
export default defineConfig({ export default defineConfig({
plugins: [react()], plugins: [react()],
css: { css: {
postcss: { postcss: {
plugins: [nesting, tailwindcss, autoprefixer] plugins: [nesting, tailwindcss, autoprefixer],
} },
}, },
resolve: { resolve: {
alias: { alias: {
'@': path.resolve(__dirname, './src') '@': path.resolve(__dirname, './src'),
} },
}, },
define: { define: {
DEV_SERVER: JSON.stringify(process.env.NODE_ENV === 'development') DEV_SERVER: JSON.stringify(process.env.NODE_ENV === 'development'),
}, },
server: { server: {
port: 6004, port: 6004,
host: '0.0.0.0',
proxy: { proxy: {
'/api': { '/api': {
target: 'http://localhost:3000', target: 'http://localhost:3000',
changeOrigin: true, changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, '/api') rewrite: (path) => path.replace(/^\/api/, '/api'),
} },
} '/api/router': {
} target: 'ws://localhost:3003',
}) changeOrigin: true,
ws: true,
rewriteWsOrigin: true,
rewrite: (path) => path.replace(/^\/api/, '/api'),
},
},
},
});