user2810903
user2810903

Reputation: 71

Vue.js - Pre complie without using build tool

I'm using Vue.js framework for my PHP + JS application with using full build of vue. i.e. directly including Vue via a script tag without a build tool.

Now my question is How can I pre-compile my templates without any build tools(Webpack, Browserify).

Thanks in advance

Upvotes: 2

Views: 974

Answers (3)

FitzFish
FitzFish

Reputation: 8629

Well, that's a strange question. I guess you are talking about compiling string templates.

It seems obvious that you can't pre-compile your template without any dedicated build tool.

You have at least two solutions to use Vue without build engine, but none of them includes pre-compiling of string templates:

  1. Use the full build of Vue (with compiler included), which can compile your string templates on the fly during execution. It's actually very lightweight and (almost) unnoticeable performance-wise for small to medium app. If you don't want to use any commonJS module and only use it in script tag, you can use the UMD build. It is availible there: https://unpkg.com/vue

  2. You can use render functions directly instead of templates, so you don't need to compile anything. See: https://v2.vuejs.org/v2/guide/render-function.html

Upvotes: 0

Franck Freiburger
Franck Freiburger

Reputation: 28538

(disclamer: author here)

vue3-sfc-loader, that works for Vue2 & Vue3, allows you to load .vue files directly from the browser without any build step. Here some examples

Upvotes: 0

ssp singh
ssp singh

Reputation: 152

  • First Install Vue-cli for Node.js as Global
  • Then you can use this command to compile *.vue files to *.js
  • Which can be used in Browser

vue-cli build --prod --lib Hello.vue -w

Upvotes: 1

Related Questions