build: support Android 9 WebView
This commit is contained in:
parent
6cb7132e22
commit
eb7c1b8d63
@ -36,11 +36,13 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/js": "^9.31.0",
|
"@eslint/js": "^9.31.0",
|
||||||
|
"@vitejs/plugin-legacy": "^7.2.1",
|
||||||
"@vitejs/plugin-vue": "^6.0.1",
|
"@vitejs/plugin-vue": "^6.0.1",
|
||||||
"eslint": "^9.31.0",
|
"eslint": "^9.31.0",
|
||||||
"eslint-plugin-vue": "~10.3.0",
|
"eslint-plugin-vue": "~10.3.0",
|
||||||
"globals": "^16.3.0",
|
"globals": "^16.3.0",
|
||||||
"sass-embedded": "^1.92.1",
|
"sass-embedded": "^1.92.1",
|
||||||
|
"terser": "^5.49.0",
|
||||||
"unplugin-vue-components": "^29.0.0",
|
"unplugin-vue-components": "^29.0.0",
|
||||||
"vite": "^7.0.6",
|
"vite": "^7.0.6",
|
||||||
"vite-plugin-vue-devtools": "^8.0.0"
|
"vite-plugin-vue-devtools": "^8.0.0"
|
||||||
|
|||||||
@ -1,14 +1,19 @@
|
|||||||
import vue from '@vitejs/plugin-vue'
|
import vue from '@vitejs/plugin-vue'
|
||||||
|
import legacy from '@vitejs/plugin-legacy'
|
||||||
import Components from 'unplugin-vue-components/vite'
|
import Components from 'unplugin-vue-components/vite'
|
||||||
|
|
||||||
import { defineConfig } from 'vite'
|
import { defineConfig } from 'vite'
|
||||||
import fs from 'node:fs'
|
import fs from 'node:fs'
|
||||||
import path from 'node:path'
|
import path from 'node:path'
|
||||||
|
import process from 'node:process'
|
||||||
import { fileURLToPath, URL } from 'node:url'
|
import { fileURLToPath, URL } from 'node:url'
|
||||||
import { VantResolver } from 'unplugin-vue-components/resolvers'
|
import { VantResolver } from 'unplugin-vue-components/resolvers'
|
||||||
|
|
||||||
const PRODUCTION_LIKE_MODES = new Set(['production', 'production-atu'])
|
const PRODUCTION_LIKE_MODES = new Set(['production', 'production-atu'])
|
||||||
const STRIPPABLE_CONSOLE_METHODS = ['log', 'debug', 'info']
|
const STRIPPABLE_CONSOLE_METHODS = ['log', 'debug', 'info']
|
||||||
|
// Android 9 首发设备可能仍使用 Chrome 69 级别的 System WebView。
|
||||||
|
// 显式锁定最低目标,避免 Vite 大版本升级后默认 target 再次抬高。
|
||||||
|
const ANDROID_9_WEBVIEW_TARGETS = ['Chrome >= 69', 'ChromeAndroid >= 69']
|
||||||
const LOCAL_OSS_MIME_TYPES = {
|
const LOCAL_OSS_MIME_TYPES = {
|
||||||
'.gif': 'image/gif',
|
'.gif': 'image/gif',
|
||||||
'.jpg': 'image/jpeg',
|
'.jpg': 'image/jpeg',
|
||||||
@ -319,6 +324,12 @@ export default defineConfig(({ mode }) => {
|
|||||||
Components({
|
Components({
|
||||||
resolvers: [VantResolver()],
|
resolvers: [VantResolver()],
|
||||||
}),
|
}),
|
||||||
|
legacy({
|
||||||
|
// Chrome 69 已支持 ESM,只需要降级现代模块并补齐实际使用的 ES API。
|
||||||
|
modernTargets: ANDROID_9_WEBVIEW_TARGETS,
|
||||||
|
modernPolyfills: true,
|
||||||
|
renderLegacyChunks: false,
|
||||||
|
}),
|
||||||
createBuildLogControlPlugin(stripDebugLogs),
|
createBuildLogControlPlugin(stripDebugLogs),
|
||||||
],
|
],
|
||||||
resolve: {
|
resolve: {
|
||||||
@ -345,9 +356,6 @@ export default defineConfig(({ mode }) => {
|
|||||||
entryFileNames: 'js/[hash].js',
|
entryFileNames: 'js/[hash].js',
|
||||||
chunkFileNames: 'js/[hash].js',
|
chunkFileNames: 'js/[hash].js',
|
||||||
assetFileNames: (assetInfo) => {
|
assetFileNames: (assetInfo) => {
|
||||||
const info = assetInfo.name.split('.')
|
|
||||||
const ext = info[info.length - 1]
|
|
||||||
|
|
||||||
if (/\.(css)$/.test(assetInfo.name)) {
|
if (/\.(css)$/.test(assetInfo.name)) {
|
||||||
return 'css/[hash].[ext]'
|
return 'css/[hash].[ext]'
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user