简体   繁体   中英

Partially integrate VueJS with Rails existing app

Current state

I have a website fully developed in Rails, using Rails views, classic Coffescript and SCSS. All my routes are declared on routes.rb.

What it's needed

Some of the pages developed have a lot of logic associated with, and it makes more sense to migrate it to a web app. The chosen web app was Vue.js.

The whole website (a very complex product) will be incrementally deployed (when the page using Vue.js is ready, the page on the Rails app should be 'replaced' by the new one). A major constraint is that the codebase is different . The Vue.js app will get information from the Rails app API.

Problems (help needed)

How can I set that some routes goes to the Rails app, and others go to the Vue.js app? (remember that are different codebases, different 'physical folders')

Thanks in advance.

Have you checked out the webpacker project?

If your vue project is already in single vue components, then you can import the component into rails projects.

To get started, please follow the readme of webpacker .

At your rails' view.

<%= javascript_pack_tag 'components/vue' %>

This way, you can continue to use rails' route.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM