Skip to content

Commit bcd4710

Browse files
author
Pooya Parsa
committed
perf: move init outside of plugin
1 parent 88961d4 commit bcd4710

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Diff for: lib/plugin.template.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@ const baseURL = process.browser
9696
? (process.env.API_URL_BROWSER || '<%= options.browserBaseURL %>')
9797
: (process.env.API_URL || '<%= options.baseURL %>')
9898

99+
// Custom init hook
100+
<% if (options.init) { %>
101+
const initHook = <%= serialize(options.init).replace('init(', 'function(').replace('function function', 'function') %>
102+
<% } %>
103+
99104
export default <% if (options.init) { %>async<% } %>(ctx, inject) => {
100105
const { app, store, req } = ctx
101106

@@ -126,11 +131,6 @@ export default <% if (options.init) { %>async<% } %>(ctx, inject) => {
126131
headers
127132
})
128133

129-
// Custom init hook
130-
<% if (options.init) { %>
131-
const initHook = <%= serialize(options.init).replace('init(', 'function(').replace('function function', 'function') %>
132-
<% } %>
133-
134134
<% if (options.credentials) { %>
135135
// Send credentials only to relative and API Backend requests
136136
axios.interceptors.request.use(config => {

0 commit comments

Comments
 (0)