- step-1:
# npm install @vitejs/plugin-vue-jsx
- step-2:
// vite.config.ts
import vuejsx from '@vitejs/plugin-vue-jsx' // support tsx component
export default defineConfig({
// 在 plugins 配置 vuejsx 的构造函数, 让项目支持 tsx 形式组件
plugins: [vue(), vuejsx({})]
}
- 安装依赖:
npm install sass -D
- 重新运行:
npm run dev
- npm run build: 生成
dist
- 将
dist
整体 拷贝至nginx/html
目录下 start nginx
: 启动nginx
服务nginx -s reload
: 重启nginx
服务- 浏览器查看
http://localhost:3343/
:2000
是3343
配置的端口
- api 代理修改配置才能让让接口前缀指向接口URL
location /gdszyepro {
proxy_pass https://epro-ps231-gdszy.test.viewchain.net/gdszyepro;
}
location /api {
proxy_pass https://gitlab.devops.viewchain.net;
}
- Install dependencies:
npm i jest vue-jest babel-jest -D
jest-vue-preprocessor
is needed for making jest understand .vue files, and babel-jest for the integration with Babel.npm i jest-vue-preprocessor -D
npm i -D vue-test-utils
- add following jest configration in the package.json
"jest": {
"moduleNameMapper": {
"^vue$": "vue/dist/vue.common.js"
},
"moduleFileExtensions": [
"js",
"vue"
],
"transform": {
"^.+\\.js$": "<rootDir>/node_modules/babel-jest",
".*\\.(vue)$": "<rootDir>/node_modules/vue-jest"
}
}
# JUST A FLAG For 开发环境
ENV = 'development'
# API BASE URL
VITE_APP_BASE_API=https://epro.test.viewchain.net/epro # OK
VITE_APP_TITLE=Leslie Release Tool # OK
VITE_APP_TEST_ATTR=Leslie Release Tool # OK
VITE_TEST_ATTR=Leslie Release Tool # OK
TEST_ATTR=Leslie ATTR # NOT
- 必须以
VITE_
开头,配置完之后需要重新启动项目或者打包项目
- To achieve, you can create an
env.d.ts
insrc
directory, then augmentImportMetaEnv
like this:
interface ImportMetaEnv {
VITE_APP_TITLE: string
// more env variables...
}