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
environments/review-front-deve-otr6gc/deployments/10515
Kasper Seweryn 2022-02-22 12:57:30 +01:00
rodzic 5e24160375
commit 3b78ac8cc6
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B2BA6FA597595C00
3 zmienionych plików z 19 dodań i 3 usunięć

8
front/src/jquery.js vendored 100644
Wyświetl plik

@ -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

Wyświetl plik

@ -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(() => {

Wyświetl plik

@ -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: {