build(uni-helper): 引入 @uni-helper/vite-plugin-uni-platform

This commit is contained in:
Burt 2024-01-04 14:35:01 +08:00
parent f101449b3c
commit 141b2cd46d
5 changed files with 16 additions and 3 deletions

View File

@ -97,6 +97,7 @@
"@uni-helper/uni-ui-types": "^0.5.11",
"@uni-helper/unocss-preset-uni": "^0.2.5",
"@uni-helper/vite-plugin-uni-pages": "^0.2.13",
"@uni-helper/vite-plugin-uni-platform": "^0.0.4",
"@vue/runtime-core": "^3.2.45",
"@vue/tsconfig": "^0.1.3",
"autoprefixer": "^10.4.16",

9
pnpm-lock.yaml generated
View File

@ -112,6 +112,9 @@ devDependencies:
'@uni-helper/vite-plugin-uni-pages':
specifier: ^0.2.13
version: 0.2.13(@types/lodash-es@4.17.12)(lodash-es@4.17.21)(lodash@4.17.21)
'@uni-helper/vite-plugin-uni-platform':
specifier: ^0.0.4
version: 0.0.4
'@vue/runtime-core':
specifier: ^3.2.45
version: 3.3.13
@ -3974,6 +3977,12 @@ packages:
- supports-color
dev: true
/@uni-helper/vite-plugin-uni-platform@0.0.4:
resolution: {integrity: sha512-aQnhpiLpxlxr6C2i6FsEbY6aFJH1igZUC5DsqoDscD/dBnpCPnovW9bFL/ig8qHsq87iAnqwhZtEpsLrzgrDaw==}
dependencies:
'@uni-helper/uni-env': 0.0.3
dev: true
/@unocss-applet/preset-applet@0.7.8:
resolution: {integrity: sha512-KWzYD88eRf7hMa0SZv8X19eT1X1fwkInM47cjNZ36i/2brt77DSnZF3y61F1zxzdf28SRH/wzgkm2e0I7JepCQ==}
dependencies:

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

3
uni-pages.d.ts vendored
View File

@ -7,8 +7,7 @@ interface NavigateToOptions {
url: "pages/index/index" |
"pages/demo/index" |
"pages/my/index" |
"pages/throughout/index" |
"pages/index/components/demo";
"pages/throughout/index";
}
interface RedirectToOptions extends NavigateToOptions {}

View File

@ -3,6 +3,9 @@ import { defineConfig, loadEnv } from 'vite'
import Uni from '@dcloudio/vite-plugin-uni'
// @see https://uni-helper.js.org/vite-plugin-uni-pages
import UniPages from '@uni-helper/vite-plugin-uni-pages'
// @see https://github.com/uni-helper/vite-plugin-uni-platform
// 需要与 @uni-helper/vite-plugin-uni-pages 插件一起使用
import UniPlatform from '@uni-helper/vite-plugin-uni-platform'
import dayjs from 'dayjs'
import svgLoader from 'vite-svg-loader'
import { visualizer } from 'rollup-plugin-visualizer'
@ -44,8 +47,9 @@ export default ({ command, mode }) => {
console.log(process.env.UNI_PLATFORM) // 得到 mp-weixin, h5 等
return defineConfig({
plugins: [
// UniPages() 需要在 Uni() 之前引入
UniPages({ exclude: ['**/components/**/**.*'] }),
UniPlatform(),
// UniXX() 都需要在 Uni() 之前引入
Uni(),
UnoCSS(),
process.env.UNI_PLATFORM === 'h5' && htmlPlugin(env.VITE_APP_TITLE),