Skip to content

Instantly share code, notes, and snippets.

@megakevin
Created October 8, 2026 22:54
Show Gist options
  • Select an option

  • Save megakevin/ae4c6964512b32124828d772d37070f6 to your computer and use it in GitHub Desktop.

Select an option

Save megakevin/ae4c6964512b32124828d772d37070f6 to your computer and use it in GitHub Desktop.
Prompt for copilot to create a Vue 2 to 3 migration guide.

In this code base, I've started work on migrating and modernizing a Vue frontend. From Vue 2 to Vue 3. This is the last part of a larger job where I'm converting a Rails 5 + Vue 2 + Webpacker app into a Rails 8 + Vue 3 + Vite app. The backend work and foundational frontend setup is done. That is, Rails 8 and Vite are working. And Vue 3 has been already installed and configured; and, as a proof of concept, a small portion of the frontend code base has already been migrated and modernized and is working. This small portion is essentially the app's main layout, the router with one smoke-test route, a minimal pinia store that defines global app state, and some foundational Spraypaint models.

The new Vue 3 code is in the app/frontend directory, and it currently implements the small portion of the frontend that I mentioned above. Importantly, it demonstrates the general vision of what I want the final frontend code to be organized like, once everything is migrated. It demonstrates the overall architecture, the file structure, the code styling, the naming conventions, etc. Under the old_codebase directory, there's the original Vue 2 code. I've added it here for reference. I've extracted the files from the old Rails 5 + Vue 2 + Webpacker code base that are relevant to the frontend and put them there.

I want you to help me create a sort of "migration guide" document that captures the design decisions and conventions of how the new code base should be written. How the old code should be translated and be adapted to the new standards, conventions, and architecture. The purpose of this file is to serve as guidance for future agents and human developers to perform the migration work. I want it to read mostly like a series of rules explaining how to handle the migration of a particular type of component, or file, or situation, etc. The idea is for it to be tailored and specific to this code base, so it should not focus too much on known general Vue 2 vs Vue 3 changes. For that, we have the official migration guide. This is not that. This is a guide to modernize this particular code base. Like I said, the code in app/frontend already demonstrates some of the final vision.

I'm going to share some of the facts and decisions that I've been able to identify already. Help me prepare the document. Add anything more that you think are missing. And adapt the ones I give you if necessary to fit the document's tone and intent. Here's what I found/decided so far while working on the migration:

  • The frontend code will have a new directory/file structure. It goes as follows:
    • The assets dir will store image files and any other static assets.
    • The components dir will store most of the Vue components used to compose the various screens. They will be stored as regular ComponentName.vue files.
    • The entrypoints dir will store the entry point files for Vite to bundle. Only application.js, active_admin.js and active_admin.scss are meant to live here. They are already there.
    • The filters dir will store filter functions.
    • The layouts dir will store layout Vue components. This app has only one, which is already defined there: MainLayout.vue.
    • The models dir will store the Spraypaint models.
    • The router dir will store the application router built using vue-router.
    • The stores dir will store this app's single store.
    • The styles dir will store any CSS/SCSS file that needs to be extracted. Only a _variables.scss is needed which is already there.
    • The views dir will store all the Vue components which represent "views" (AKA "pages" or "screens"). These are the ones that the router's routes point to directly.
    • The App.vue file is the root Vue component.
  • The new code will use Vue's options API, like the old code. It won't use the composition API.
  • Vue components go into *.vue files named after the component, and into the components dir. Instead of how the old code did it. The old code used named directories after the components and used index.vue files inside of those directories. A weird setup that we will no longer use.
  • Filters are no longer supported in Vue 3 in the same way that they were in Vue 2 with "|" in templates. So we have to just call them as methods normally.
  • The old code has a logger component. We wont use that in the new code.
  • The vue-awesome package does not support Vue 3. It's been replaced by @fortawesome/vue-fontawesome. So the new code will use that instead. It's already been setup in the project. Components that need fontawesome icons will have to import FontAwesomeIcon and use that. Luckily its a clean swap for the most part.
  • The vue-breadcrumbs package does not support Vue 3. And I haven't found an alternative that maps cleanly. We will need to find an alternative or implement something similar on our own. One of the tricky things is that it integrated with the old Vue router using the breadcrumb: field in the route definitions. Let's not deal with this right at the beginning of work, leave this for towards the end.
  • The vue-carousel package does not support Vue 3. And I haven't found an alternative that maps cleanly. We will need to find an alternative or implement something similar on our own. Let's not deal with this right at the beginning of work, leave this for towards the end.
  • The vue-notification package does not support Vue 3. And I haven't found an alternative that maps cleanly. We will need to find an alternative or implement something similar on our own. Let's not deal with this right at the beginning of work, leave this for towards the end.
  • The spraypaint-vue package (https://github.com/graphiti-api/spraypaint-vue) does not support Vue 3. And I haven't found an alternative that maps cleanly. Apparently all this package does is enhance the ApplicationRecord.sync = true; feature of Spraypaint so that instances are able to be properly garbage collected after they are done being used. It does this by calling #unlisten() when Vue components are being destroyed. The old code uses this, but the new one does not yet. I'd imagine this would cause memory leak problems, when ApplicationRecord.sync = true; is enabled. I'm not sure whether we actually need this. But if we do, we will need to figure out how to handle it in the new code. Maybe implement what spraypaint-vue does ourselves, for Vue 3. Looking at the code from spraypaint-vue, it doesn't look too complex. Let's not deal with this right at the beginning of work, leave this for towards the end.
  • The old code, in its app bootstrapping logic in application.js, does a lot of weird things to load components and make them available globally. The new code wont do any of that. Components will be loaded explicitly when needed.
  • The old code used vuex for global state management. The new code uses pinia. For the most part, this is a clean-ish swap. But still there are differences in how stores are defined and how vue components interact with the stores. For example, pinia does not have mutations, so the old store and the components that interact with it will have to be rewritten to some extent to do things the pinia way. Also, the new code will have only one store. pinia supports many but we will use only one. We have called it the AppStore.
  • The old code uses actioncable-vue and the new one will too. Luckily actioncable-vue supports Vue 3 and it mostly seems like a clean-ish swap. But the way of doing certain things have changed. We need to upgrade and adapt.
  • The old code uses a few polyfills. The new code won't use any polyfills.
  • The old code uses the event bus pattern, implemented using a Vue instance, to emit and listen to events across unrelated components. Vue 3 does not support this. So the new code will use the mitt and mitt-vue packages. This is not at all set up yet.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment