[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 * @param {APIError} error
*/ */
export function onUnhandledAPIError (error) { export function onUnhandledAPIError (error) {
// In 'development', Babel seems to also catch the error so there's no need to log it twice. error.log()
if (process.env.NODE_ENV !== 'development') {
error.log()
}
store.dispatch('HANDLE_ERROR', error) store.dispatch('HANDLE_ERROR', error)
} }

View file

@ -1,3 +1,12 @@
// helper module to expose custom and vuelidate validators. // helper module to expose custom and vuelidate validators.
export * from './customValidators' 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) { async function loadDateFnsLocale (locale) {
const dateFnsLocaleName = supportedLocales[locale].dateFnsLocale || locale const dateFnsLocaleName = supportedLocales[locale].dateFnsLocale || locale
return import( dateFnsLocale = (await import(
`date-fns/locale/${dateFnsLocaleName}/index.js` `../../node_modules/date-fns/esm/locale/${dateFnsLocaleName}/index.js`
).then(locale => { )).default
dateFnsLocale = locale.default
})
} }
/** /**

View file

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

View file

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

View file

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