Skip to content
Advertisement

Build typescript vue apps with only babel?

How can I transpile and build my typescript vue app with only babel? I used the vue-cli-service extensively but reached a point where I just need a minimal setup, without webpack or anything.

My .babelrc

JavaScript

My package.json dependencies:

JavaScript

My entry main.ts file:

JavaScript

My App.vue

JavaScript

My build script:

JavaScript

Advertisement

Answer

Unfortunately you cannot build with babel, as it only transpiles languages and it cannot build modules. You will still need some type of bundler to resolve require / import imports. If you don’t want giant hefty webpack configs you can look at Rollup or Parcel

If you want to actually just compile you typescript and vue typescript you need to install @babel/preset-typescript @babel/preset-env, include them in .babelrc file.

Then use babel ./src/main.ts --out-dir build --extensions ".ts" or better yet use locally installed babel ./node_modules/.bin/babel ./src/main.ts --out-dir build --extensions ".ts"

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement