| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- import {defineConfig, loadEnv} from 'vite'
- import path from 'path'
- import createVitePlugins from './vite/plugins'
- // https://vitejs.dev/config/
- export default defineConfig(({mode, command}) => {
- const env = loadEnv(mode, process.cwd())
- const {VITE_APP_ENV} = env
- return {
- // プロダクション環境と開発環境でのURLのデプロイ。
- // 既定では、viteはアプリケーションがドメインのルートパス上に配置されていると仮定します。
- // アプリケーションがサブパス上に配置されている場合は、このオプションを使用してそのサブパスを指定する必要があります。
- base: VITE_APP_ENV === 'production' ? '/' : '/',
- plugins: createVitePlugins(env, command === 'build'),
- resolve: {
- // https://cn.vitejs.dev/config/#resolve-alias
- alias: {
- // パスの設定
- '~': path.resolve(__dirname, './'),
- // エイリアスの設定
- '@': path.resolve(__dirname, './src')
- },
- // https://cn.vitejs.dev/config/#resolve-extensions
- extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue']
- },
- // vite 関連の設定
- server: {
- port: 80,
- host: true,
- open: true,
- proxy: {
- // https://cn.vitejs.dev/config/#server-proxy
- '/dev-api': {
- target: 'http://localhost:9080',
- changeOrigin: true,
- rewrite: (p) => p.replace(/^\/dev-api/, '')
- }
- }
- },
- //fix:error:stdin>:7356:1: warning: "@charset" must be the first rule in the file
- css: {
- postcss: {
- plugins: [
- {
- postcssPlugin: 'internal:charset-removal',
- AtRule: {
- charset: (atRule) => {
- if (atRule.name === 'charset') {
- atRule.remove();
- }
- }
- }
- }
- ]
- }
- }
- }
- })
|