import vue from '@vitejs/plugin-vue2';
import { resolve } from 'path';
import pxtovw from 'postcss-px-to-viewport';
const loder_pxtovw = pxtovw({
unitToConvert: "px",
viewportWidth: 375,
unitPrecision: 2,
})
export default {
plugins: [
vue(),
],
css: {
postcss: {
plugins: [loder_pxtovw]
}
},
resolve: {
alias: {
'@': resolve(__dirname, 'src')
}
},
build: {
rollupOptions: {
output: {
entryFileNames: 'js/[name]-[hash].js',
chunkFileNames: 'js/[name]-[hash].js',
assetFileNames (assetInfo) {
if (assetInfo.name.endsWith('.css')) {
return 'css/[name]-[hash].css'
}
const imgExts = ['.png', '.jpg', '.jpeg', '.webp', '.gif', '.svg']
if (imgExts.some(ext => assetInfo.name.endsWith(ext))) {
return 'img/[name]-[hash].[ext]'
}
const fontsExts = ['.ttf', '.woff', '.woff2', '.eot']
if (fontsExts.some(ext => assetInfo.name.endsWith(ext))) {
return 'fonts/[name]-[hash].[ext]'
}
const mediaExts = ['.mp4', '.mp3', '.webm']
if (mediaExts.some(ext => assetInfo.name.endsWith(ext))) {
return 'media/[name]-[hash].[ext]'
}
return 'assets/[name]-[hash].[ext]'
}
},
},
},
server: {
open: true,
cors: true,
proxy: {
'/XYH': {
target: 'http://xxx.com',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/XYH/, '')
}
},
},
}
import Vue from 'vue'
import App from './App.vue'
import router from '@/router'
import store from '@/store'
import '@vant/touch-emulator';
import { Button, Icon, Swipe, } from 'vant';
import 'vant/lib/index.css'
import '@/assets/style/global.css'
const components = [
Button, Icon, Swipe,
]
components.forEach(item => {
Vue.use(item)
})
Vue.config.productionTip = false
const on = Vue.prototype.$on
Vue.prototype.$on = function (event, func) {
let previous = 0
let newFunc = func
if (event === 'click') {
newFunc = function () {
const now = new Date().getTime()
if (previous + 1500 <= now) {
func.apply(this, arguments)
previous = now
}
}
}
on.call(this, event, newFunc)
}
new Vue({
render: h => h(App),
router,
store,
}).$mount('#app')