Compile a ".vue" component in browser, with JS only? Compile a ".vue" component in browser, with JS only? vue.js vue.js

Compile a ".vue" component in browser, with JS only?


It doesn't make sense to compile in the browser when it's so much more efficient to just pre-compile your component locally instead of relying on a visitor's client to do it.

In fact, the answer above regarding vue-http-loader says it's only for use in development and links to this article: https://vuejs.org/2015/10/28/why-no-template-url/

With that said, I created a vue-cli template that lets you pre-compile .vue files into a single .js files you can use in the browser. The single JS file contains the template, script, and styles. It uses webpack, but it's super easy to run and watches your files as you edit them.

$ vue init RonnieSan/vue-browser-sfc my-project

Repo at: https://github.com/RonnieSan/vue-browser-sfc

Instructions are in the README.