Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible to set this up when use Vue with Vanilla JS (not .vue) #50

Open
chopfitzroy opened this issue Feb 27, 2017 · 7 comments
Open

Comments

@chopfitzroy
Copy link

Hey I recently posted an issue on vue-router about not being able to properly hot reload vue components with Vanilla JS (at the time I thought it was vue-router).

I have a demo repo here that demonstrates the problem but I will quickly explain it here also.

Basically I am using Vue without .vue files this is simply because I find my workflow (syntax highlighting, how I structure my SASS, etc...) works better using Vanilla JS files. I am requiring .html files using the webpack html-loader as the component template like so:

export default {
    name: 'Home',
    // ...
    template: require('./Home.html')
}
<!-- Home.html -->
<div>
    <p>
        <router-link to="/test-one">Test One</router-link>
    </p>
    <p>
        <router-link to="/test-two">Test Two</router-link>
    </p>
</div>

Is there a way I can set up the vue-hot-reload-api to work with this?

@Toilal
Copy link

Toilal commented Mar 16, 2017

You could try this loader : https://github.com/ktsn/vue-hot-reload-loader or this one : https://github.com/jshmrtn/vue-hot-loader.

First one seems a bit better, but for some reason I can't make it work with typescript. reload is called on api, but it has no effect.

@Toilal
Copy link

Toilal commented Mar 16, 2017

I just found the issue on vue-hot-reload-loader, you can try my Pull Request available on my fork, it works like a charm.

@chopfitzroy
Copy link
Author

Awesome :) thanks @Toilal

@Toilal
Copy link

Toilal commented Mar 16, 2017 via email

@Toilal
Copy link

Toilal commented Mar 20, 2017

I wrote a fork of official webpack template that supports Hot Module Reload out of the box for people who don't want to use vue-loader and .vue single component files. It also support a TypeScript option.

https://github.com/Toilal/vue-webpack-template

@chopfitzroy
Copy link
Author

chopfitzroy commented Mar 21, 2017

Hey @Toilal & @yyx990803,

Is there any chance of this getting merged back in to the official repo?

Cheers.

@Toilal
Copy link

Toilal commented Mar 22, 2017

I don't think main repo will allow merging this back because it advocates for not using .vue single component files. This is a really personnal choice and vue dev team promotes using .vue files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants