12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- import { defineConfig, loadEnv } from 'vite'
- import legacy from '@vitejs/plugin-legacy'
- import { createVuePlugin } from 'vite-plugin-vue2'
- import viteCompression from 'vite-plugin-compression'
- import path from 'path'
- // import eslintPlugin from 'vite-plugin-eslint'
- const HOST = '0.0.0.0'
- const REPLACEMENT = `${path.resolve(__dirname, './src')}/`
- export default ({ mode }) => {
- const env = loadEnv(mode, process.cwd())
- return defineConfig({
- base: './',
- server: {
- host: HOST,
- port: process.env.PORT
- },
- define: {
- 'process.env': { ...env }
- },
- resolve: {
- alias: [
- {
- find: '@/',
- replacement: REPLACEMENT
- },
- {
- find: 'src/',
- replacement: REPLACEMENT
- }
- ],
- extensions: ['.vue', '.js', '.jsx', '.json']
- },
- esbuild: { loader: { '.js': '.jsx' }},
- plugins: [
- createVuePlugin({
- jsx: true
- }),
- // eslintPlugin(),
- legacy({
- targets: ['ie >= 11'],
- additionalLegacyPolyfills: ['regenerator-runtime/runtime']
- }),
- viteCompression()
- ]
- })
- }
|