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.

Share Improve this question edited Jul 9, 2017 at 20:38 Bert 82.5k17 gold badges203 silver badges166 bronze badges asked Oct 17, 2016 at 10:19 Dan MindruDan Mindru 6,1144 gold badges30 silver badges42 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 9

standalone 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