updates to frontend-react
This commit is contained in:
95
Web/WebSocket/websocket/apps/frontend-react/vite.config.ts
Normal file
95
Web/WebSocket/websocket/apps/frontend-react/vite.config.ts
Normal file
@@ -0,0 +1,95 @@
|
||||
import type {UserConfig} from 'vite';
|
||||
|
||||
import path from 'node:path';
|
||||
import {defineConfig} from 'vite';
|
||||
import VitePluginReact from '@vitejs/plugin-react-swc';
|
||||
import ViteBabelPlugin from 'vite-plugin-babel';
|
||||
|
||||
// https://vite.dev/config/
|
||||
export default defineConfig(({mode}) => {
|
||||
const isProductionMode = mode === 'production';
|
||||
|
||||
// optional: const modeDependentEnvironmentVariables = loadEnv(mode, process.cwd()); // https://vite.dev/config/#using-environment-variables-in-config
|
||||
return {
|
||||
define: {},
|
||||
root: path.resolve(process.cwd()),
|
||||
publicDir: 'public',
|
||||
cacheDir: 'node_modules/.vite', // default is `node_modules/.vite` <-- https://vite.dev/config/shared-options.html#cachedir
|
||||
base: '/',
|
||||
mode,
|
||||
resolve: {
|
||||
alias: {
|
||||
assets: path.resolve(process.cwd(), 'src/assets'),
|
||||
components: path.resolve(process.cwd(), 'src/components'),
|
||||
services: path.resolve(process.cwd(), 'src/services'),
|
||||
store: path.resolve(process.cwd(), 'src/store'),
|
||||
styles: path.resolve(process.cwd(), 'src/styles'),
|
||||
themes: path.resolve(process.cwd(), 'src/themes'),
|
||||
utils: path.resolve(process.cwd(), 'src/utils'),
|
||||
views: path.resolve(process.cwd(), 'src/views')
|
||||
},
|
||||
dedupe: [],
|
||||
conditions: ['module', 'browser', 'development|production'], // default is `['module', 'browser', 'development|production']`
|
||||
mainFields: ['browser', 'module'], // default is `['browser', 'module', 'jsnext:main', 'jsnext']`
|
||||
extensions: ['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json'],
|
||||
preserveSymlinks: false // default is false
|
||||
},
|
||||
css: {
|
||||
modules: undefined, // default is `undefined`
|
||||
// postcss: {},
|
||||
devSourcemap: true, // default is `false` **experimental Vite feature**
|
||||
transformer: 'postcss' // default is `postcss` **experimental Vite feature**
|
||||
},
|
||||
json: {
|
||||
stringify: true // default is 'auto' // https://vite.dev/config/shared-options.html#json-stringify
|
||||
},
|
||||
esbuild: {
|
||||
jsxFactory: 'h',
|
||||
jsxFragment: 'Fragment',
|
||||
jsxInject: `import React from 'react'`
|
||||
},
|
||||
logLevel: 'debug', // default is `info`
|
||||
clearScreen: false, // default is `true`
|
||||
envDir: '.',
|
||||
appType: 'spa',
|
||||
server: {
|
||||
host: 'localhost',
|
||||
allowedHosts: ['localhost', '.phenixrts.com'],
|
||||
port: 5173,
|
||||
open: true,
|
||||
hmr: true,
|
||||
fs: {
|
||||
strict: true,
|
||||
deny: ['.env', '.env.*', '*.{crt,pem}', '**/.git/**'] // default is `['.env', '.env.*', '*.{crt,pem}', '**/.git/**']`
|
||||
}
|
||||
},
|
||||
build: {
|
||||
target: ['es2020', 'chrome80', 'firefox78', 'safari14'],
|
||||
outDir: 'dist',
|
||||
assetsDir: 'assets',
|
||||
assetsInlineLimit: 4096, // default is `4096` ~ 4KiB
|
||||
cssCodeSplit: true,
|
||||
minify: isProductionMode,
|
||||
cssMinify: isProductionMode,
|
||||
sourcemap: !isProductionMode,
|
||||
manifest: false, // default is `false`<-- https://vite.dev/config/build-options.html#build-manifest ,
|
||||
ssrManifest: false,
|
||||
ssr: false,
|
||||
emitAssets: false,
|
||||
terserOptions: {},
|
||||
emptyOutDir: true,
|
||||
copyPublicDir: true,
|
||||
reportCompressedSize: true,
|
||||
chunkSizeWarningLimit: 500,
|
||||
watch: null
|
||||
},
|
||||
plugins: [
|
||||
VitePluginReact(),
|
||||
ViteBabelPlugin({
|
||||
babelConfig: {
|
||||
plugins: ['transform-amd-to-commonjs', 'babel-plugin-styled-components']
|
||||
}
|
||||
})
|
||||
]
|
||||
} satisfies UserConfig;
|
||||
});
|
||||
Reference in New Issue
Block a user