This commit is contained in:
BIN
.env.development
BIN
.env.development
Binary file not shown.
BIN
.env.production
BIN
.env.production
Binary file not shown.
@ -5,7 +5,7 @@
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vue-tsc -b && vite build",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
@ -19,4 +19,4 @@
|
||||
"vite": "^6.3.5",
|
||||
"vue-tsc": "^2.2.8"
|
||||
}
|
||||
}
|
||||
}
|
18
src/App.vue
18
src/App.vue
@ -1,19 +1,13 @@
|
||||
<template>
|
||||
|
||||
<HelloWorld />
|
||||
</template>
|
||||
|
||||
|
||||
<script setup lang="ts">
|
||||
import HelloWorld from './components/HelloWorld.vue'
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<a href="https://vite.dev" target="_blank">
|
||||
<img src="/vite.svg" class="logo" alt="Vite logo" />
|
||||
</a>
|
||||
<a href="https://vuejs.org/" target="_blank">
|
||||
<img src="./assets/vue.svg" class="logo vue" alt="Vue logo" />
|
||||
</a>
|
||||
</div>
|
||||
sfgdfgdfhfgh
|
||||
<HelloWorld msg="Vite + 高峰过后结双方的果很快ui哦山豆根豆腐干里噢批哦就将很快" />
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.logo {
|
||||
|
@ -1,17 +1,27 @@
|
||||
|
||||
<template>
|
||||
|
||||
<div>
|
||||
<img :src="url" alt=""/>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from 'vue';
|
||||
|
||||
let url=ref('')
|
||||
|
||||
onMounted(()=>{
|
||||
const publicPath = import.meta.env.VITE_PUBLIC;
|
||||
console.log('环境变量 VITE_PUBLIC:', publicPath);
|
||||
console.log('所有环境变量:', import.meta);
|
||||
|
||||
url.value = publicPath + 'ui/背景.png'
|
||||
console.log('最终图片路径:', url.value);
|
||||
})
|
||||
|
||||
|
||||
const bg = import.meta.env.VITE_BG
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<style scoped>
|
||||
.read-the-docs {
|
||||
color: #888;
|
||||
}
|
||||
</style>
|
||||
<style scoped></style>
|
||||
|
@ -1,7 +1,47 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import { defineConfig, loadEnv } from 'vite'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import { resolve } from 'path'
|
||||
|
||||
// https://vite.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [vue()],
|
||||
export default defineConfig(({ mode }) => {
|
||||
const env = loadEnv(mode, process.cwd());
|
||||
|
||||
return {
|
||||
base: './', //打包后的相对路径
|
||||
|
||||
server: {
|
||||
host: true,
|
||||
port: 8080, //vite项目启动时自定义端口
|
||||
|
||||
open: true,
|
||||
proxy: {
|
||||
// 正则表达式写法
|
||||
'^/api': {
|
||||
target: 'http://192.168.3.151:3000/api', // 后端服务实际地址
|
||||
changeOrigin: true, //开启代理
|
||||
rewrite: (path) => path.replace(/^\/api/, '')
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
plugins: [
|
||||
vue(),
|
||||
],
|
||||
|
||||
resolve: {
|
||||
//别名
|
||||
alias: {
|
||||
'@': resolve(__dirname, './src'),
|
||||
components: resolve(__dirname, './src/components'),
|
||||
script: resolve(__dirname, './src/script'),
|
||||
utils: resolve(__dirname, './src/utils'),
|
||||
stores: resolve(__dirname, './src/stores')
|
||||
}
|
||||
},
|
||||
build: {
|
||||
assetsDir: 'static', //打包后的公共文件夹名
|
||||
target: 'es2015',
|
||||
cssTarget: ['chrome61'],
|
||||
chunkSizeWarningLimit: 5000
|
||||
}
|
||||
}
|
||||
})
|
||||
|
Reference in New Issue
Block a user