-
Notifications
You must be signed in to change notification settings - Fork 806
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Question] How to utilize vue-runtime build? #1052
Comments
Are you using single file components? |
@DrJonki Yes, all the components in the project will be single file components. I suppose that's kind of necessary to get the pre-compilation? |
@DrJonki That's why I can't figure out what's wrong. I get the following error when I use the runtime build:
And I don't have any items hanging around for the runtime build to compile.. 😕 |
I presume passing data to the component doesn't count as compiling, because I do have some of those |
@sausin Can you show how you instantiate your Vue instance and what the mount point looks like in your HTML? |
It's a laravel project with the app.js like this:
The main layout file is like this:
|
<my-cookie-banner>
</my-cookie-banner> There's your problem. You're sending HTML with a custom element, which Vue will pick up on, but being unable to handle rendering it, missing the template compiler and all :P Try something like this: const root = require('./components/MyCookieBanner.vue');
const app = new Vue({
el: '#app',
render: createElement => createElement(root) //< The important line
}); EDIT: In addition you shouldn't have anything inside |
@DrJonki Thanks for looking into this ! I have several components and several pages which use different components. How would I go about doing this? Also, not sure what you meant by
How do I define where the vue component should 'come up'? Sorry for being thick, if this should've been obvious 😕 |
What I like to do, is to have a separate 'root' component (as a .vue file). In the template of the root component I would lay out the rest of the page layout. In other words, take everything you have inside |
@DrJonki Thanks for the tip! I think I got it 👍 |
@sausin But this doesn't solve the CSP issue with "eval" function used in the compiled app.js |
I have used this below code and it's official |
Description:
Vue comes with a runtime build which allows for CSP compliance.
Steps To Reproduce:
The following addition to the
webpack.mix.js
allowsmix
to use the runtime version:This compiles the resources find but does not work during runtime as the templates are not compiled to render functions. In the link above, it is suggested that
webpack
+vue-loader
can be used to pre-compile the templates.However, I couldn't find a way to do this. It would be great if this could be included in the docs. If it is already included, please forgive my ignorance and point me to it 😃
The text was updated successfully, but these errors were encountered: