12.1.0
https://jsbin.com/vuvumeduza/edit?html,output
Hello.vue should be the main file for the componenet
Hello.js is the file pointed by vue.esm.js
I was following this guide to separate my <template> and <script>:
https://vuejs.org/v2/guide/single-file-components.html#What-About-Separation-of-Concerns
However, it seems filenames for .vue and .js files would have to be different for the @component. Otherwise the vue-loader would pick up the .js file for the @component, resulting the error: "Failed to mount component: template or render function not defined."
If you introduce the .js file after the dev server is running, vue-loader would still process the .vue file first. But running dev server from cold boot would make the .js file as the main file for @component.
Example:
Hello.vue:
<template>
<div class='hello'></hello>
</template>
<script src='./Hello.js'></script> //Doesn't work on dev server cold boot
<script src='./HelloController.js'></script> //Works
If won't fix, then maybe make a note on the documentation about the filename requirements when separating them.
If you have two files with the same name, use explicit file extensions in imports.
Alternatively, change this line to resolve .vue first:
https://github.com/vuejs-templates/webpack/blob/master/template/build/webpack.base.conf.js#L22
I faced with same problem, maybe we should have warning section in manual ? or right webpack configuration from the defaul vue-cli ?
This configuration is not "wrong". I think it's correct to prefer is files, they are the standard files in JS apps after all.
Most helpful comment
If you have two files with the same name, use explicit file extensions in imports.
Alternatively, change this line to resolve .vue first:
https://github.com/vuejs-templates/webpack/blob/master/template/build/webpack.base.conf.js#L22