6

I have an existing angular application and I want to start changing some of it to a vueJS application.

My application, in dev mode, loads all scripts in the main html file (in production mode its bundled into app.js but I want to start testing to dev mode).

I want to change on of the states to use vue, so I read it's possible in the following way: https://medium.lucaskatayama.com/migrating-from-angular-to-vuejs-71277cdc3dd9

However, I want to use a .vue files syntax and I don't know if that's possible without using webpack or any other bundler in dev mode.

So my question is - Is that possible? Can I use .vue files inside my ng app with the current configurations? Furthermore, is there a nice way to webpack only the vue files and components (even though I have to initialize them inside and angular controller as it seems).

If there are any good tutorials for adding vue into angular app, I would love to get them, as I failed finding good ones.

Thanks

1
  • .vue files are a format used by vue-loader, an npm package designed specifically for webpack. So, if you want to use .vue files I'm pretty sure you need webpack. Commented Oct 30, 2017 at 14:46

2 Answers 2

4

ngVue member here :)

At Dawex (the company I'm working at), we're using Vue within a big AngularJS application, with ngVue. It's in production for several months now and it works very well. You can find more informations on this article I wrote before last summer: https://medium.com/dailyjs/how-to-migrate-from-angularjs-to-vue-4a1e9721bea8. Hope that helps!

Sign up to request clarification or add additional context in comments.

Comments

2

That could be tough, because the build for the vue code will basically be a separate application.

One thing you could do is build them as completely different parallel apps, use two build steps, include two javscript files and then use window.postMessage to communicate between the two.

So for example your current application will come to a point where a particular div is to contain vue code instead of angular. You could then post a message from your angular code, telling the vue app to load into that div, e.g.:

window.postMessage({ app: 'vue', bind: '#vue-content' })

The vue app, instead of binding on DOMContentReady would listen to window events, and then bind to the element it receives. It would then communicate back to the host app by posting messages also. This would keep them fairly seperate and allow you to build them independently.

3 Comments

I must say, I kind off like this idea. Gave me some inspiration on our migration project as well!
Thanks Justin! Two questions - first, would you do that? would you try to add vue into an existing and pretty large angular application? Second, any thoughts about ngVue?
I have not looked at ngVue at all but if someone has already done some work for you may as well check it out. And regarding doing it at all... it seems risky and I would probably rather not do it but if you can't think of a better way to get traction towards moving away from old angular than I would be awfully tempted.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.