How to enable runtime template compiler? #4158
-
I'm using components which are sent from API and loaded via |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 11 replies
-
I have a similar (the same) issue. We're building a new application using Vue 3 that is backed by a headless content management system (CMS), to implement a multi-tenanted financial application. We have a number of custom components that are used from within the CMS content to manage transactional financial data (display and interaction). Since the content is coming from the CMS, it needs to be compiled at runtime to include the component functionality. I've been experimenting with the various implementations of Like you, @Thomasan1999, we could do this using the Vue-Cli/ From reading the From the // vue.config.js
module.exports = {
configureWebpack: {
resolve: {
alias: {
vue$: 'vue/dist/vue.esm-bundler.js',
// ... Looking at the initial generated configuration for import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue()]
}) So, extrapolating from the But I don't know enough about bundling, the different module types, and I suspect it's a combination of Can somebody please point me in the right direction to solve this configuration problem? I don't want to have to abandon |
Beta Was this translation helpful? Give feedback.
-
SOLUTION Okay … after more investigation, this configuration for import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
// https://vitejs.dev/config/
export default defineConfig({
resolve: {
alias: {
vue: 'vue/dist/vue.esm-bundler.js'
}
},
plugins: [
vue()
]
}) And this is my {
"name": "exp1",
"version": "0.0.0",
"scripts": {
"dev": "vite",
"build": "vue-tsc --noEmit && vite build",
"serve": "vite preview"
},
"dependencies": {
"vue": "^3.2.6",
"vue3-runtime-template": "^1.0.1"
},
"devDependencies": {
"@vitejs/plugin-vue": "^1.6.0",
"@vue/compiler-sfc": "^3.0.5",
"typescript": "^4.3.2",
"vite": "^2.5.1",
"vue-tsc": "^0.2.2"
}
} Hope this helps. Cheers, S t u a r t . |
Beta Was this translation helpful? Give feedback.
-
If anyone is coming here looking for vue 2 with vite adding this worked for me:
|
Beta Was this translation helpful? Give feedback.
-
For me this didn't do it as dist is only generated after it needed the esm bundler. This worked for me, also make sure __dirname is set! |
Beta Was this translation helpful? Give feedback.
-
It worked for me in Vue 2 like this: ` import * as path from "path";
` |
Beta Was this translation helpful? Give feedback.
SOLUTION
Okay … after more investigation, this configuration for
vite.config.ts
is working for me, and it's successfully including the runtime compiler:And this is my
package.json
: