Workaround axios-auth-refresh in production
axios-auth-refresh has only prebuilt files, that might be the case when vite is trying to bundle it. It seems like vite thinks that it's constructed like: ``` export default { default () { // ... } } ``` This also fixes `jQuery is not defined` in dev
This commit is contained in:
parent
5e24160375
commit
3b78ac8cc6
|
@ -0,0 +1,8 @@
|
|||
import jQuery from 'jquery'
|
||||
|
||||
// NOTE: Workaround for fomantic-ui-css
|
||||
if (import.meta.env.DEV) {
|
||||
window.$ = window.jQuery = jQuery
|
||||
}
|
||||
|
||||
export default jQuery
|
|
@ -1,7 +1,7 @@
|
|||
// The Vue build version to load with the `import` command
|
||||
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
|
||||
import logger from '@/logging'
|
||||
import jQuery from 'jquery'
|
||||
import jQuery from '@/jquery'
|
||||
|
||||
import Vue from 'vue'
|
||||
import moment from 'moment'
|
||||
|
@ -13,7 +13,7 @@ import store from './store'
|
|||
import GetTextPlugin from 'vue-gettext'
|
||||
import { sync } from 'vuex-router-sync'
|
||||
import locales from '@/locales'
|
||||
import createAuthRefreshInterceptor from 'axios-auth-refresh'
|
||||
import axiosAuthRefresh from 'axios-auth-refresh'
|
||||
|
||||
import filters from '@/filters' // eslint-disable-line
|
||||
import { parseAPIErrors } from '@/utils'
|
||||
|
@ -158,6 +158,13 @@ const refreshAuth = (failedRequest) => {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: This seems like a vite error, in production it thinks that
|
||||
// axiosAuthRefresh is a following object: { default () { /* ... */} }
|
||||
// Maybe we need to tweak the config?
|
||||
const createAuthRefreshInterceptor = import.meta.env.DEV
|
||||
? axiosAuthRefresh
|
||||
: axiosAuthRefresh.default
|
||||
|
||||
createAuthRefreshInterceptor(axios, refreshAuth)
|
||||
|
||||
store.dispatch('instance/fetchFrontSettings').finally(() => {
|
||||
|
|
|
@ -29,7 +29,8 @@ export default defineConfig({
|
|||
build: {
|
||||
// NOTE: For debugging builds
|
||||
// TODO: Remove before #1664 is merged
|
||||
sourcemap: 'inline'
|
||||
sourcemap: 'inline',
|
||||
transformMixedEsModules: true
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
|
|
Loading…
Reference in New Issue