import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from 'path';
import postCssPxToRem from "postcss-pxtorem";
export default defineConfig({
base: "./",
plugins: [vue()],
resolve: {
alias: {
'@': resolve(__dirname, './src'),
'^': resolve(__dirname, './src/views'),
'#': resolve(__dirname, './src/components')
}
},
css: {
postcss: {
plugins: [
postCssPxToRem({
rootValue: 75,
propList: ['*'],
mediaQuery: true,
})
]
},
preprocessorOptions: {
stylus: {
imports: [resolve(__dirname, 'src/stylus/...styl')]
}
}
},
build: {
minify: 'terser',
terserOptions: {
compress: {
drop_console: true,
drop_debugger: true,
},
},
rollupOptions: {
output: {
entryFileNames: 'static/js/[name]-[hash].js',
chunkFileNames: 'static/js/[name]-[hash].js',
assetFileNames: assetInfo => {
var info = assetInfo.name.split('.')
var extType = info[info.length - 1]
if (/\.(png|jpe?g|gif|svg)(\?.*)?$/.test(assetInfo.name)) {
extType = 'img'
} else if (/\.(woff2?|eot|ttf|otf)(\?.*)?$/i.test(assetInfo.name)) {
extType = 'fonts'
}
return `static/${extType}/[name]-[hash][extname]`
},
}
}
},
})