Sfoglia il codice sorgente

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

Burt 2 anni fa
parent
commit
141b2cd46d
5 ha cambiato i file con 16 aggiunte e 3 eliminazioni
  1. 1 0
      package.json
  2. 9 0
      pnpm-lock.yaml
  3. BIN
      screenshots/uni-platform.png
  4. 1 2
      uni-pages.d.ts
  5. 5 1
      vite.config.ts

+ 1 - 0
package.json

@@ -97,6 +97,7 @@
     "@uni-helper/uni-ui-types": "^0.5.11",
     "@uni-helper/uni-ui-types": "^0.5.11",
     "@uni-helper/unocss-preset-uni": "^0.2.5",
     "@uni-helper/unocss-preset-uni": "^0.2.5",
     "@uni-helper/vite-plugin-uni-pages": "^0.2.13",
     "@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/runtime-core": "^3.2.45",
     "@vue/tsconfig": "^0.1.3",
     "@vue/tsconfig": "^0.1.3",
     "autoprefixer": "^10.4.16",
     "autoprefixer": "^10.4.16",

+ 9 - 0
pnpm-lock.yaml

@@ -112,6 +112,9 @@ devDependencies:
   '@uni-helper/vite-plugin-uni-pages':
   '@uni-helper/vite-plugin-uni-pages':
     specifier: ^0.2.13
     specifier: ^0.2.13
     version: 0.2.13(@types/lodash-es@4.17.12)(lodash-es@4.17.21)(lodash@4.17.21)
     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':
   '@vue/runtime-core':
     specifier: ^3.2.45
     specifier: ^3.2.45
     version: 3.3.13
     version: 3.3.13
@@ -3974,6 +3977,12 @@ packages:
       - supports-color
       - supports-color
     dev: true
     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:
   /@unocss-applet/preset-applet@0.7.8:
     resolution: {integrity: sha512-KWzYD88eRf7hMa0SZv8X19eT1X1fwkInM47cjNZ36i/2brt77DSnZF3y61F1zxzdf28SRH/wzgkm2e0I7JepCQ==}
     resolution: {integrity: sha512-KWzYD88eRf7hMa0SZv8X19eT1X1fwkInM47cjNZ36i/2brt77DSnZF3y61F1zxzdf28SRH/wzgkm2e0I7JepCQ==}
     dependencies:
     dependencies:

BIN
screenshots/uni-platform.png


+ 1 - 2
uni-pages.d.ts

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

+ 5 - 1
vite.config.ts

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