@@ -64,6 +64,7 @@ export default function ContentModule(moduleOpts) {
6464 const contentDirWebpackAlias = '~/' + CONTENT_DIR
6565 const port =
6666 process . env . PORT || process . env . npm_package_config_nuxt_port || 3000
67+
6768 const isDev = this . nuxt . options . dev
6869 const loaderComponentExtensions = [ '.vue' , '.js' ]
6970
@@ -115,8 +116,25 @@ export default function ContentModule(moduleOpts) {
115116 } )
116117 } )
117118
118- // 2. Build dynamic content pages without components (*.md)
119- buildContent ( this , BUILD_DIR , routesOptions )
119+ this . nuxt . plugin ( 'build' , builder => {
120+ // 1. Initialize axios module
121+ this . requireModule ( [
122+ '@nuxtjs/axios' ,
123+ {
124+ baseURL : api . baseURL + api . serverPrefix ,
125+ browserBaseURL :
126+ api . baseURL +
127+ ( builder . isStatic ? api . browserPrefix : api . serverPrefix )
128+ }
129+ ] )
130+
131+ // 2. Build dynamic content pages without components (*.md)
132+ buildContent ( this , BUILD_DIR , builder . isStatic , routesOptions )
133+ } )
134+
135+ this . addPlugin ( {
136+ src : resolve ( __dirname , 'plugins/requestContent.js' )
137+ } )
120138
121139 // 3. Add content API
122140 const router = createRouter ( api , routesOptions )
@@ -138,22 +156,7 @@ export default function ContentModule(moduleOpts) {
138156 } )
139157 } )
140158
141- // 4. Add request helpers
142- this . requireModule ( [
143- '@nuxtjs/axios' ,
144- {
145- baseURL : api . baseURL + api . serverPrefix ,
146- browserBaseURL :
147- api . baseURL +
148- ( process . env . STATIC ? api . browserPrefix : api . serverPrefix )
149- }
150- ] )
151-
152- this . addPlugin ( {
153- src : resolve ( __dirname , 'plugins/requestContent.js' )
154- } )
155-
156- // 5. Add Vue templates generated from markdown to output build
159+ // 4. Add Vue templates generated from markdown to output build
157160 this . addPlugin ( {
158161 src : resolve ( __dirname , 'plugins/markdownComponents.template.js' ) ,
159162 options : {
0 commit comments