diff --git a/packages/@vue/cli-service/generator/index.js b/packages/@vue/cli-service/generator/index.js index c36edede16..05a497a5e8 100644 --- a/packages/@vue/cli-service/generator/index.js +++ b/packages/@vue/cli-service/generator/index.js @@ -1,6 +1,7 @@ module.exports = (api, options) => { api.render('./template', { - doesCompile: api.hasPlugin('babel') || api.hasPlugin('typescript') + doesCompile: api.hasPlugin('babel') || api.hasPlugin('typescript'), + useBabel: api.hasPlugin('babel') }) if (options.vueVersion === '3') { @@ -74,4 +75,9 @@ module.exports = (api, options) => { if (options.configs) { api.extendPackage(options.configs) } + + // Delete jsconfig.json when typescript + if (api.hasPlugin('typescript')) { + api.render((files) => delete files['jsconfig.json']) + } } diff --git a/packages/@vue/cli-service/generator/template/jsconfig.json b/packages/@vue/cli-service/generator/template/jsconfig.json new file mode 100644 index 0000000000..fc75f22038 --- /dev/null +++ b/packages/@vue/cli-service/generator/template/jsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "target": "<%- options.useBabel ? 'esnext' : 'es5' %>", + "module": "esnext", + "baseUrl": "./", + "moduleResolution": "node", + "paths": { + "@/*": [ + "src/*" + ] + }, + "lib": [ + "esnext", + "dom", + "dom.iterable", + "scripthost" + ] + } +}