Skip to content

Commit

Permalink
fix: 🐛 优化web-rsbuild模板
Browse files Browse the repository at this point in the history
  • Loading branch information
MuyianKing committed Nov 14, 2024
1 parent 060eb36 commit a2281a2
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 39 deletions.
15 changes: 6 additions & 9 deletions cli/template/web/rsbuild/.env
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
# 公共配置
PUBLIC_WEB_NAME = "楼宇管理"
PUBLIC_VERSION = "0.0.1"
PUBLIC_PROJECT_PREFIX = "PowseringCenter"
VITE_WEB_NAME = RsbuildTemplate
VITE_VERSION = 0.0.1
VITE_PROJECT_PREFIX = RsbuildTemplate

# 是否开启https 0-关闭 1-开启
PUBLIC_HTTPS = '1'
VITE_HTTPS = 1

# 是否开启gzip 0-关闭 1-开启
PUBLIC_GZIP = "0"

# 是否需要兼容老版本浏览器 0-关闭 1-开启
PUBLIC_POLYFILL_OLD_BROWSER = "0"
VITE_GZIP = 0

# iconify图标库的后台地址
PUBLIC_ICONIFY_API = "/json/json"
VITE_ICONIFY_API = /json/json
4 changes: 2 additions & 2 deletions cli/template/web/rsbuild/.env.development
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# 公司开发环境
PUBLIC_BASE_URL = "http://192.168.10.106:28084"
VITE_BASE_URL = http://192.168.10.106:28084

# 是否开启跨域 1-开启 2-关闭
PUBLIC_CORS = "2"
VITE_CORS = 2
6 changes: 3 additions & 3 deletions cli/template/web/rsbuild/.env.production
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# 生产环境
PUBLIC_BASE_URL = ""
VITE_BASE_URL = ""

# 是否需要兼容老版本浏览器 0-关闭 1-开启
PUBLIC_POLYFILL_OLD_BROWSER = "1"
VITE_POLYFILL_OLD_BROWSER = 1

# 是否开启跨域 1-开启 2-关闭
PUBLIC_CORS = "2"
VITE_CORS = 2
5 changes: 3 additions & 2 deletions cli/template/web/rsbuild/.vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"recommendations": [
"dbaeumer.vscode-eslint",
"vue.volar",
"wayou.vscode-todo-highlight"
"wayou.vscode-todo-highlight",
"MuyianKing.mu-code-snippets"
]
}
}
2 changes: 1 addition & 1 deletion cli/template/web/rsbuild/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ export default antfu({
},
}, ...compat.config({
extends: [
'./app/.eslintrc-auto-import.json',
'./.eslintrc-auto-import.json',
],
}))
22 changes: 11 additions & 11 deletions cli/template/web/rsbuild/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
},
"dependencies": {
"@hl/directions": "^0.7.0",
"@hl/hooks": "^0.7.0",
"@hl/hooks": "^0.7.2",
"@hl/theme-chalk": "^0.7.0",
"@hl/tyyh": "^0.6.2",
"@hl/ui": "^0.7.1",
"@hl/utils": "^0.6.2",
"@hl/tyyh": "^0.7.0",
"@hl/ui": "^0.7.2",
"@hl/utils": "^0.7.1",
"@multiavatar/multiavatar": "^1.0.7",
"@vueuse/core": "^11.2.0",
"axios": "^1.7.7",
Expand All @@ -35,7 +35,7 @@
"nanoid": "^5.0.8",
"nprogress": "^0.2.0",
"pinia": "^2.2.6",
"pinia-plugin-persistedstate": "^4.1.2",
"pinia-plugin-persistedstate": "^4.1.3",
"validator": "^13.12.0",
"vue": "^3.5.12",
"vue-clipboard3": "^2.0.0",
Expand All @@ -45,26 +45,26 @@
"wavesurfer.js": "^7.8.8"
},
"devDependencies": {
"@antfu/eslint-config": "^3.8.0",
"@antfu/eslint-config": "^3.9.1",
"@commitlint/cli": "^19.5.0",
"@commitlint/config-conventional": "^19.5.0",
"@eslint/eslintrc": "^3.1.0",
"@iconify/vue": "^4.1.2",
"@rsbuild/core": "1.0.19",
"@rsbuild/core": "1.1.1",
"@rsbuild/plugin-basic-ssl": "^1.1.1",
"@rsbuild/plugin-image-compress": "^1.0.2",
"@rsbuild/plugin-sass": "1.1.0",
"@rsbuild/plugin-vue": "1.0.3",
"@rsbuild/plugin-vue": "1.0.4",
"@vue/compiler-sfc": "^3.5.12",
"cross-env": "^7.0.3",
"cz-git": "^1.10.1",
"cz-git": "^1.11.0",
"eslint": "^9.14.0",
"eslint-plugin-format": "^0.1.2",
"husky": "^9.1.6",
"lint-staged": "^15.2.10",
"sass": "^1.80.6",
"sass": "^1.80.7",
"tailwindcss": "^3.4.14",
"unplugin-auto-import": "^0.18.3",
"unplugin-auto-import": "^0.18.4",
"unplugin-element-plus": "^0.8.0",
"unplugin-vue-components": "^0.27.4"
},
Expand Down
5 changes: 4 additions & 1 deletion cli/template/web/rsbuild/rsbuild.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import path from 'node:path'
import { defineConfig } from '@rsbuild/core'
import { defineConfig, loadEnv } from '@rsbuild/core'
import { pluginImageCompress } from '@rsbuild/plugin-image-compress'
import { pluginSass } from '@rsbuild/plugin-sass'
import { pluginVue } from '@rsbuild/plugin-vue'
Expand All @@ -9,10 +9,12 @@ import Components from 'unplugin-vue-components/rspack'
import useAlias from './alias.config'

const { alias_map } = useAlias()
const { publicVars } = loadEnv({ prefixes: ['VITE_'] })

export default defineConfig({
html: {
template: './public/index.html',
title: publicVars['import.meta.env.VITE_WEB_NAME'].replace(/"/g, ''),
},
plugins: [
pluginVue(),
Expand Down Expand Up @@ -58,6 +60,7 @@ export default defineConfig({
},
source: {
alias: alias_map,
define: publicVars,
include: [
path.resolve(__dirname, '../packages/task/src'),
/[\\/]node_modules[\\/]/,
Expand Down
6 changes: 3 additions & 3 deletions cli/template/web/rsbuild/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const user = computed(() => {
</template>

<style lang="scss">
@import '@style/custome.scss';
@import '@style/main.scss';
@import '@style/utils.scss';
@use '@style/custome.scss';
@use '@style/main.scss';
@use '@style/utils.scss';
</style>
2 changes: 1 addition & 1 deletion cli/template/web/rsbuild/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import router from '@/router'
import api from '@api'
import { BASE_URL, ICONIFY_API, PROJECT_PREFIX, WEB_NAME } from '@app'
import * as common from '@hl/utils/es/common'
import * as message from '@hl/utils/es/message'
import * as message from '@hl/ui/src/utils/message'
import http from '@http'
import { addAPIProvider, disableCache, enableCache } from '@iconify/vue'
import Token from '@server/token'
Expand Down
10 changes: 5 additions & 5 deletions cli/template/web/rsbuild/src/utils/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ export const ENV_MODE = ['development', 'development.outer'].includes(import.met
export const MODE = import.meta.env.MODE

// 应用名称
export const WEB_NAME = import.meta.env.PUBLIC_WEB_NAME
export const WEB_NAME = import.meta.env.VITE_WEB_NAME

// 系统缓存统一前缀
export const PROJECT_PREFIX = import.meta.env.PUBLIC_PROJECT_PREFIX
export const PROJECT_PREFIX = import.meta.env.VITE_PROJECT_PREFIX

// 接口基本地址
export const BASE_URL = import.meta.env.PUBLIC_BASE_URL
export const BASE_URL = import.meta.env.VITE_BASE_URL

// 是否跨域
export const CORS = import.meta.env.PUBLIC_CORS
export const CORS = import.meta.env.VITE_CORS

// 图标服务地址
export const ICONIFY_API = import.meta.env.PUBLIC_ICONIFY_API
export const ICONIFY_API = import.meta.env.VITE_ICONIFY_API
2 changes: 1 addition & 1 deletion cli/template/web/rsbuild/src/views/Login.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script name="UserLoginNoAlive" setup>
import { useRequest } from '@/hooks/useRequest'
import { useRequest } from '@hl/hooks'
import { clearUserData, login } from '@server/user'
const form = reactive({
Expand Down

0 comments on commit a2281a2

Please sign in to comment.