ktsn / vue-auto-routing

Generate Vue Router routing automatically
MIT License
254 stars 19 forks source link

Error occurs when deleting vue file while webpack is watching #6

Open ryugonomura opened 5 years ago

ryugonomura commented 5 years ago

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.

ktsn commented 5 years ago

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.

mhelaiwa commented 3 years ago

I am using "laravel-mix:^6.0.29" / "webpack": "^5.38.1" and having the same issue.

  1. Deleting a vue or chaning it's name throus an error.
  2. New added pages are not seen by vue-auto-routing unless you kill the watch process and run it again.
mhelaiwa commented 3 years ago

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?

mhelaiwa commented 3 years ago

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,
    ...
})
mhelaiwa commented 3 years ago

the outFile option needs to be added to the docs