admin管理员组文章数量:1405170
Went with the runtime-only
build version of Vue.js for a new project. I saw in the docs that to switch to the standalone
one needs to add an alias to webpack, like so:
resolve: {
alias: {
'vue$': 'vue/dist/vue.js'
}
}
At the moment, I don't need the piler in my app. However, it's possible that at some point I will need to switch to the standalone
build.
My question is:
Will it be a painless switch between runtime-only
and standalone
later or will it require heavy refactoring?
If it does, I might as well start with standalone
and avoid refactoring later on.
Went with the runtime-only
build version of Vue.js for a new project. I saw in the docs that to switch to the standalone
one needs to add an alias to webpack, like so:
resolve: {
alias: {
'vue$': 'vue/dist/vue.js'
}
}
At the moment, I don't need the piler in my app. However, it's possible that at some point I will need to switch to the standalone
build.
My question is:
Will it be a painless switch between runtime-only
and standalone
later or will it require heavy refactoring?
If it does, I might as well start with standalone
and avoid refactoring later on.
1 Answer
Reset to default 9standalone
supports template option in ponents. For example, you can do this:
Vue.ponent('my-ponent', {
template: '<div>A custom ponent!</div>'
})
standalone
also allows you to load vue.js
from a CDN, like you would do with jQuery or any other javascript library.
runtime-only
does not allow you to use template
in ponent definition. So you need to create my-ponent.vue
file and define template inside as detailed in Single File Components guide: http://vuejs/guide/single-file-ponents.html
Also you need to use vue-cli
for development, if you are using runtime-only
.
To switch from standalone
to runtime-only
, you will have to rewrite all the ponents into my-ponent.vue
files, and start using vue-cli
To switch from runtime-only
to standalone
, there are no changes required.
Other than that, it is painless to switch between runtime-only
and standalone
.
My preference: runtime-only
only mode, as it produces much smaller builds and theoretically performs better, as templates are pre-piled. Also the sections in vue
file are well organized and easy to read. Separate vue files for ponents also forces you to structure your app better.
本文标签: javascriptChanging Vuejs from standalone to runtimeonly build later in a projectStack Overflow
版权声明:本文标题:javascript - Changing Vue.js from standalone to runtime-only build later in a project? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744273643a2598306.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论