123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- import postCssPxToRem from 'postcss-pxtorem'
- import { defineConfig, loadEnv } from 'vite'
- import path from 'path'
- import createVitePlugins from './vite/plugins'
- export default defineConfig(({ mode, command }) => {
-
- const env = loadEnv(mode, process.cwd())
- const { VITE_APP_ENV } = env
- return {
-
-
- base: VITE_APP_ENV === 'production' ? '/' : './',
- plugins: createVitePlugins(env, command === 'build'),
- resolve: {
-
- alias: {
-
- '~': path.resolve(__dirname, '/'),
-
- '@': path.resolve(__dirname, 'src')
- },
-
- extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue']
- },
-
- server: {
- port: 9053,
- host: '0.0.0.0',
- proxy: {
-
- '/dev-api': {
- target: 'https://www.baidu.com',
-
- changeOrigin: true,
- rewrite: (p) => p.replace(/^\/dev-api/, '')
- }
- },
- hmr: true,
- usePolling: true
- },
- css: {
- devSourcemap: true,
- postcss: {
- plugins: [
-
-
-
-
-
- require('autoprefixer')({
- overrideBrowserslist: [
- 'Android 4.1',
- 'iOS 7.1',
- 'Chrome > 31',
- 'ff > 31',
- 'ie >= 8',
- '> 1%'
- ],
- grid: true
- }),
- require('postcss-flexbugs-fixes'),
- {
- postcssPlugin: 'internal:charset-removal',
- AtRule: {
- charset: (atRule) => {
- if (atRule.name === 'charset') {
- atRule.remove();
- }
- }
- }
- }
- ]
- },
- preprocessorOptions: {
- scss: {
-
- additionalData: '@import "@/assets/style/global.scss";',
- }
- }
- },
- build: {
- assetsDir: 'static',
- rollupOptions: {
- external: [],
- output: {
- chunkFileNames: 'static/js/[name]-[hash].js',
- entryFileNames: 'static/js/[name]-[hash].js',
- assetFileNames: 'static/[ext]/name-[hash].[ext]',
- manualChunks(id) {
-
- if (id.includes(path.resolve(__dirname, '/src/store/index.js'))) {
- return 'vendor';
- }
- }
- }
- }
- }
- }
- })
|