vue-h5-template/vite.config.ts
2022-05-20 02:04:36 +08:00

47 lines
1.2 KiB
TypeScript

import vue from '@vitejs/plugin-vue';
import vueJsx from '@vitejs/plugin-vue-jsx';
import { resolve } from 'path';
import { ConfigEnv, UserConfigExport } from 'vite';
import { createStyleImportPlugin, NutuiResolve } from 'vite-plugin-style-import';
import { viteMockServe } from 'vite-plugin-mock';
import eruda from 'vite-plugin-eruda';
const pathResolve = (dir: string) => resolve(__dirname, dir);
// https://vitejs.dev/config/
export default function ({ command }: ConfigEnv): UserConfigExport {
const isProduction = command === 'build';
console.log(isProduction);
return {
server: {
host: '0.0.0.0',
},
plugins: [
vue(),
vueJsx(),
createStyleImportPlugin({
resolves: [NutuiResolve()],
}),
eruda(),
viteMockServe({
mockPath: './src/mock',
localEnabled: command === 'serve',
logger: true,
}),
],
css: {
preprocessorOptions: {
scss: {
// 配置 nutui 全局 scss 变量
additionalData: `@import "@nutui/nutui/dist/styles/variables.scss";`,
},
},
},
resolve: {
alias: {
'@': pathResolve('./src'),
},
},
};
}