Error occurs when deleting vue file while webpack is watching
Execute the "webpack --mode development --watch" command from the following URL. The following error occurs when deleting a newly created vuefile. https://github.com/rymizuki/example-vue-auto-routing
ERROR in ./src/pages/hogehoge.vue Module build failed (from ./node_modules/vue-loader/lib/index.js): Error: ENOENT: no such file or directory, open 'C:\dev\project\example-vue-auto-routing\src\pages\hogehoge.vue' @ ./node_modules/vue-auto-routing/index.js 3:18-73 @ ./src/router.js @ ./node_modules/vue-loader/lib??vue-loader-options!./src/App.vue?vue&type=script&lang=js& @ ./src/App.vue?vue&type=script&lang=js& @ ./src/App.vue @ ./src/index.js
Also, when creating a vuefile while running "webpack --mode development --watch", a new route will not be written to the "./node_modules/vue-loader/lib/index.js" file.
Hmm, that's weird. Actually the test code contains such case (adding / removing page component during watch) and it passes. It may be some difference between webpack Node API and CLI. I'll look into it deeper later.
I am using "laravel-mix:^6.0.29" / "webpack": "^5.38.1" and having the same issue.
- Deleting a vue or chaning it's name throus an error.
- New added pages are not seen by
vue-auto-routingunless you kill the watch process and run it again.
I think that the problem is kind of caching problem.
the file vue-auto-routing/index.js is always correct but import routes from 'vue-auto-routing' not always bring the latest copy of the routs.
Any Ideas to fix that?
For me I used the outFile option and it does the job. I see some build errors momentarily but it's OK for me as it rebuilds after that with no errors.
This will force laravel-mix to reload the changes from the file because it's within the watch scope
module.exports = {
plugins: [
new VueAutoRoutingPlugin({
pages: 'src/pages',
importPrefix: '@/pages/',
outFile:'./resources/js/routes.js',
})
]
}
import autoRoutes from './routes';
const router = new Router({
...
routes: allRoutes,
...
})
the outFile option needs to be added to the docs