40 lines
821 B
TypeScript
40 lines
821 B
TypeScript
import { fileURLToPath, URL } from 'node:url'
|
|
import { defineConfig } from 'vite'
|
|
import vue from '@vitejs/plugin-vue'
|
|
import { nodePolyfills } from 'vite-plugin-node-polyfills'
|
|
|
|
/** 移除 crossorigin 属性,避免部分手机浏览器加载资源异常 */
|
|
function removeCrossorigin() {
|
|
return {
|
|
name: 'remove-crossorigin',
|
|
transformIndexHtml(html: string) {
|
|
return html.replace(/\s*crossorigin\s*/g, ' ')
|
|
},
|
|
}
|
|
}
|
|
|
|
export default defineConfig({
|
|
resolve: {
|
|
alias: {
|
|
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
|
},
|
|
},
|
|
plugins: [
|
|
vue(),
|
|
nodePolyfills({
|
|
protocolImports: true,
|
|
}),
|
|
removeCrossorigin(),
|
|
],
|
|
define: {
|
|
'process.env': {},
|
|
},
|
|
build: {
|
|
target: 'es2020',
|
|
cssTarget: 'chrome64',
|
|
},
|
|
server: {
|
|
host: true,
|
|
},
|
|
})
|