@roki-h5/create-roki-app 0.1.9 → 0.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@roki-h5/create-roki-app",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "description": "Roki H5 项目脚手架",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@roki-h5/scaffold-template",
3
3
  "private": true,
4
- "version": "0.1.5",
4
+ "version": "0.1.6",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "dev": "vite --mode development",
@@ -33,7 +33,12 @@ function setupWebViewJavascriptBridge(
33
33
  window.WVJBCallbacks = [callback]
34
34
 
35
35
  const { iPhone, iPad, iPod } = browser.versions
36
- if (iPhone || iPad || iPod) {
36
+ // file:// 本地预览或桌面浏览器勿注入 bridge iframe,否则会触发跨域安全错误
37
+ const canUseIosBridgeIframe =
38
+ typeof location !== 'undefined' &&
39
+ location.protocol !== 'file:' &&
40
+ (iPhone || iPad || iPod)
41
+ if (canUseIosBridgeIframe) {
37
42
  const WVJBIframe = document.createElement('iframe')
38
43
  WVJBIframe.style.display = 'none'
39
44
  WVJBIframe.src = 'https://__bridge_loaded__'
@@ -5,7 +5,8 @@ import Home from '@/views/home/index.vue'
5
5
  const HOME_TITLE_FALLBACK = '燃气热水器'
6
6
 
7
7
  const router = createRouter({
8
- history: createWebHashHistory(import.meta.env.BASE_URL),
8
+ // file:// 下勿传 BASE_URL(./),与调料机一致,避免 pushState 异常
9
+ history: createWebHashHistory(),
9
10
  routes: [
10
11
  {
11
12
  path: '/',
@@ -56,15 +56,15 @@ export default defineConfig(({ mode }) => {
56
56
  vue(),
57
57
  legacy({
58
58
  targets: [
59
- '> 0%',
60
- 'Chrome > 4',
61
- 'Android >= 4',
62
- 'IOS >= 7',
63
- 'not ie <= 6',
64
- 'Firefox ESR',
59
+ 'iOS >= 11',
60
+ 'Chrome >= 64',
61
+ 'Android >= 64',
65
62
  ],
66
63
  renderLegacyChunks: true,
64
+ // 与调料机一致:不输出 type=module 现代包,避免 file:// / App 容器加载失败
67
65
  renderModernChunks: !legacyOnlyForFileProtocol,
66
+ polyfills: true,
67
+ additionalLegacyPolyfills: ['regenerator-runtime/runtime'],
68
68
  }),
69
69
  distHtmlPostProcess({ removeModulePreload: legacyOnlyForFileProtocol }),
70
70
  ],
@@ -92,7 +92,18 @@ export default defineConfig(({ mode }) => {
92
92
  },
93
93
  base,
94
94
  build: {
95
- cssCodeSplit: !legacyOnlyForFileProtocol,
95
+ assetsInlineLimit: 10240,
96
+ rollupOptions: legacyOnlyForFileProtocol
97
+ ? {
98
+ output: {
99
+ format: 'iife',
100
+ inlineDynamicImports: true,
101
+ chunkFileNames: 'assets/[name]-[hash].js',
102
+ entryFileNames: 'assets/[name]-[hash].js',
103
+ assetFileNames: 'assets/[name]-[hash].[ext]',
104
+ },
105
+ }
106
+ : undefined,
96
107
  },
97
108
  server: {
98
109
  host: true,