How to compile Vuejs single file component?
javascript, vue-component, vue.js, vuejs2
Solution
You will need this setting in webpack's config:
resolve: {
alias: {
'vue$': 'vue/dist/vue'
}
}
despite on this problem: http://vuejs.org/guide/installation.html#Standalone-vs-Runtime-only-Build
Problem
I am using Vuejs 2 (webpack-simple template) and I would like to know how can I compile template before render it. Below my code : App.vue ``` <template> <div id="app"> <h1>{{ msg }}</h1> </div> </template> <script> export default { name: 'app' } </script> ``` main.js ``` import Vue from 'vue' import App from './App.vue' const res = Vue.compile(App) const vm = new Vue({ el: '#app', data: { msg: 'hello' }, render: res.render, staticRenderFns: res.staticRenderFns }) ``` And these is the error that I've got when I start the server: `__WEBPACK_IMPORTED_MODULE_0_vue___default.a.compile is not a function` I also tried this plugin vue-template-compiler with no luck. Can you please help me to make it work ? Thanks in advance.