import { defineConfig } from 'vite'
import uni from '@dcloudio/vite-plugin-uni'

export default defineConfig(() => {
    return {
        base: './',
        build: {
            minify: true,
            outDir: 'dist',
        },
        server: {
            port: '80'
        },
        plugins: [
            uni()
        ],
        exclude: [
            /\/README\.md$/,
        ],
        css: {
            preprocessorOptions: {
                scss: {
                    api: 'modern-compiler'
                }
            }
        }
    }
})

module.exports = {
  configureWebpack: {
    optimization: {
      splitChunks: {
        chunks: 'async', // 仅异步代码抽离
        minSize: 20000, // 大于20KB才抽离
        cacheGroups: {
          commons: {
            name: 'commons',
            chunks: 'initial',
            minChunks: 2, // 被引用2次以上抽离
            priority: -10
          }
        }
      }
    }
  }
}