@@ -64,6 +64,7 @@ export default function ContentModule(moduleOpts) {
64
64
const contentDirWebpackAlias = '~/' + CONTENT_DIR
65
65
const port =
66
66
process . env . PORT || process . env . npm_package_config_nuxt_port || 3000
67
+
67
68
const isDev = this . nuxt . options . dev
68
69
const loaderComponentExtensions = [ '.vue' , '.js' ]
69
70
@@ -115,8 +116,25 @@ export default function ContentModule(moduleOpts) {
115
116
} )
116
117
} )
117
118
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
+ } )
120
138
121
139
// 3. Add content API
122
140
const router = createRouter ( api , routesOptions )
@@ -138,22 +156,7 @@ export default function ContentModule(moduleOpts) {
138
156
} )
139
157
} )
140
158
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
157
160
this . addPlugin ( {
158
161
src : resolve ( __dirname , 'plugins/markdownComponents.template.js' ) ,
159
162
options : {
0 commit comments