53 lines
1.4 KiB
JavaScript
53 lines
1.4 KiB
JavaScript
import { defineConfig } from "vite";
|
|
import vue from "@vitejs/plugin-vue";
|
|
import { resolve } from "path";
|
|
|
|
import styleImport, { VantResolve } from "vite-plugin-style-import";
|
|
|
|
// https://vitejs.dev/config/
|
|
export default defineConfig({
|
|
plugins: [
|
|
vue(),
|
|
styleImport({
|
|
resolves: [VantResolve()],
|
|
libs: [
|
|
{
|
|
libraryName: "vant",
|
|
esModule: true,
|
|
resolveStyle: (name) => `../es/${name}/style`, //https://blog.csdn.net/yunchong_zhao/article/details/123552423
|
|
},
|
|
],
|
|
}),
|
|
],
|
|
server: {
|
|
host: "0.0.0.0", //设置地址:http://localhost
|
|
port: 4000, // 设置服务启动端口号
|
|
hmr: false, // 关闭热更新
|
|
// open: true, // 设置服务启动时是否自动打开浏览器
|
|
// cors: true, // 允许跨域
|
|
// proxy: {
|
|
// '/api': {
|
|
// target: 'http://dining.lzyyj.com/prod-api',//代理的地址
|
|
// changeOrigin: true,
|
|
// // 路径重写 pathRewrite无效使用rewrite
|
|
// // pathRewrite: { '/api': '' // 用'/api'代替target里面的地址 },
|
|
// rewrite: path => path.replace(/^\/api/, '')
|
|
// }
|
|
// }
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
"@": resolve(__dirname, "src"),
|
|
},
|
|
},
|
|
css: {
|
|
// css预处理器
|
|
preprocessorOptions: {
|
|
scss: {
|
|
charset: false,
|
|
additionalData: '@import "./src/assets/style/index.scss";',
|
|
},
|
|
},
|
|
},
|
|
});
|