File tree 2 files changed +16
-2
lines changed
2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -82,14 +82,23 @@ module.exports = (api, projectOptions) => {
82
82
// this plugin does not play well with jest + cypress setup (tsPluginE2e.spec.js) somehow
83
83
// so temporarily disabled for vue-cli tests
84
84
if ( ! process . env . VUE_CLI_TEST ) {
85
+ let vueCompilerPath
86
+ try {
87
+ // Vue 2.7+
88
+ vueCompilerPath = require . resolve ( 'vue/compiler-sfc' )
89
+ } catch ( e ) {
90
+ // Vue 2.6 and lower versions
91
+ vueCompilerPath = require . resolve ( 'vue-template-compiler' )
92
+ }
93
+
85
94
config
86
95
. plugin ( 'fork-ts-checker' )
87
96
. use ( require ( 'fork-ts-checker-webpack-plugin' ) , [ {
88
97
typescript : {
89
98
extensions : {
90
99
vue : {
91
100
enabled : true ,
92
- compiler : isVue3 ? require . resolve ( 'vue/compiler-sfc' ) : require . resolve ( 'vue-template-compiler' )
101
+ compiler : vueCompilerPath
93
102
}
94
103
} ,
95
104
diagnosticOptions : {
Original file line number Diff line number Diff line change @@ -64,9 +64,14 @@ module.exports = (api, options) => {
64
64
const vueLoaderCacheConfig = api . genCacheConfig ( 'vue-loader' , {
65
65
'vue-loader' : require ( '@vue/vue-loader-v15/package.json' ) . version ,
66
66
'@vue/component-compiler-utils' : require ( '@vue/component-compiler-utils/package.json' ) . version ,
67
- 'vue-template-compiler' : require ( 'vue-template-compiler/package.json' ) . version
68
67
} )
69
68
69
+ try {
70
+ vueLoaderCacheConfig [ 'vue-template-compiler' ] = require ( 'vue-template-compiler/package.json' ) . version
71
+ } catch ( e ) {
72
+ // For Vue 2.7 projects, `vue-template-compiler` is not required
73
+ }
74
+
70
75
webpackConfig . resolve
71
76
. alias
72
77
. set (
You can’t perform that action at this time.
0 commit comments