5
5
const chalk = require ( 'chalk' )
6
6
7
7
module . exports = ( api , options , rootOptions ) => {
8
- // TODO cleanup for next cli release
9
- if ( ! api . hasPlugin ( 'router' ) && ! api . generator . pkg . dependencies [ 'vue-router' ] ) {
8
+ if ( ! api . hasPlugin ( 'router' ) ) {
10
9
throw new Error ( `Please install router plugin with 'vue add router'.` )
11
10
}
12
11
@@ -30,8 +29,7 @@ module.exports = (api, options, rootOptions) => {
30
29
}
31
30
32
31
const templateOptions = {
33
- // TODO cleanup for next cli release
34
- vuex : api . hasPlugin ( 'vuex' ) || api . generator . pkg . dependencies [ 'vuex' ] ,
32
+ vuex : api . hasPlugin ( 'vuex' ) ,
35
33
pwa : api . hasPlugin ( 'pwa' ) ,
36
34
apollo : api . hasPlugin ( 'apollo' ) ,
37
35
}
@@ -78,7 +76,7 @@ module.exports = (api, options, rootOptions) => {
78
76
79
77
return result
80
78
}` )
81
- contents = contents . replace ( 'createProvider().provide() ' , 'apolloProvider.provide() ' )
79
+ contents = contents . replace ( 'apolloProvider: createProvider()' , 'apolloProvider' )
82
80
fs . writeFileSync ( file , contents , { encoding : 'utf8' } )
83
81
}
84
82
}
@@ -127,7 +125,7 @@ module.exports = (api, options, rootOptions) => {
127
125
}
128
126
129
127
contents = contents . replace ( / e x p o r t d e f a u l t a p p = > { ( ( .| \s ) * ) } / , `export default app => {$1
130
- ssrMiddleware(app)
128
+ ssrMiddleware(app, { prodOnly: true } )
131
129
}` )
132
130
contents = `import { ssrMiddleware } from '@akryum/vue-cli-plugin-ssr'\n` + contents
133
131
fs . writeFileSync ( file , contents , { encoding : 'utf8' } )
@@ -139,7 +137,11 @@ module.exports = (api, options, rootOptions) => {
139
137
// Lint generated/modified files
140
138
try {
141
139
const lint = require ( '@vue/cli-plugin-eslint/lint' )
142
- lint ( { silent : true } , api )
140
+ const files = [ '*.js' , '.*.js' , 'src' ]
141
+ if ( api . hasPlugin ( 'apollo' ) ) {
142
+ files . push ( 'apollo-server' )
143
+ }
144
+ lint ( { silent : true , _ : files } , api )
143
145
} catch ( e ) {
144
146
// No ESLint vue-cli plugin
145
147
}
0 commit comments