Verified Commit 3b78ac8c authored by Kasper Seweryn's avatar Kasper Seweryn 🥞
Browse files

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
parent 5e241603
import jQuery from 'jquery'
// NOTE: Workaround for fomantic-ui-css
if (import.meta.env.DEV) {
window.$ = window.jQuery = jQuery
}
export default jQuery
// 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: {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment