[vite] fix imports and call to 'process.env'

This commit is contained in:
axolotle 2023-04-03 21:03:39 +02:00
parent bcf02d10f3
commit 0a1cab6f38
6 changed files with 22 additions and 18 deletions

View file

@ -78,10 +78,7 @@ export async function handleError (request, response, errorData) {
* @param {APIError} error
*/
export function onUnhandledAPIError (error) {
// In 'development', Babel seems to also catch the error so there's no need to log it twice.
if (process.env.NODE_ENV !== 'development') {
error.log()
}
store.dispatch('HANDLE_ERROR', error)
}

View file

@ -1,3 +1,12 @@
// helper module to expose custom and vuelidate validators.
export * from './customValidators'
export * from 'vuelidate/lib/validators'
export {
between,
helpers,
integer,
maxValue,
minLength,
minValue,
required,
sameAs
} from 'vuelidate/lib/validators'

View file

@ -61,11 +61,9 @@ function loadLocaleMessages (locale) {
*/
async function loadDateFnsLocale (locale) {
const dateFnsLocaleName = supportedLocales[locale].dateFnsLocale || locale
return import(
`date-fns/locale/${dateFnsLocaleName}/index.js`
).then(locale => {
dateFnsLocale = locale.default
})
dateFnsLocale = (await import(
`../../node_modules/date-fns/esm/locale/${dateFnsLocaleName}/index.js`
)).default
}
/**

View file

@ -54,12 +54,12 @@ Vue.prototype.$askMdConfirmation = function (markdown, props, ok = false) {
}
// Register global components
const requireComponent = require.context('@/components/globals', true, /\.(js|vue)$/i)
// For each matching file name...
requireComponent.keys().forEach((fileName) => {
// Get the component
const component = requireComponent(fileName).default
// Globally register the component
const globalComponentsModules = import.meta.glob([
'@/components/globals/*.vue',
'@/components/globals/*/*.vue'
], { eager: true })
Object.values(globalComponentsModules).forEach((module) => {
const component = module.default
Vue.component(component.name, component)
})

View file

@ -7,7 +7,7 @@ Vue.use(VueRouter)
const router = new VueRouter({
// mode: 'history', // this allow all routes to be real ones (without '#')
base: process.env.BASE_URL,
base: import.meta.env.BASE_URL,
routes,
scrollBehavior (to, from, savedPosition) {

View file

@ -84,7 +84,7 @@ export default {
const availableLocales = this.$store.getters.availableLocales
this.fields.locale.props.choices = availableLocales
this.fields.fallbackLocale.props.choices = availableLocales
if (process.env.NODE_ENV === 'development') {
if (import.meta.env.DEV) {
this.fields.experimental = {
id: 'experimental',
label: this.$i18n.t('tools_webadmin.experimental'),