vue-auto-routing icon indicating copy to clipboard operation
vue-auto-routing copied to clipboard

Error occurs when deleting vue file while webpack is watching

Open ryugonomura opened this issue 6 years ago • 5 comments

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.

ryugonomura avatar Jun 06 '19 23:06 ryugonomura

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.

ktsn avatar Jun 27 '19 08:06 ktsn

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 avatar Sep 06 '21 11:09 mhelaiwa

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 avatar Sep 06 '21 11:09 mhelaiwa

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 avatar Sep 06 '21 23:09 mhelaiwa

the outFile option needs to be added to the docs

mhelaiwa avatar Sep 06 '21 23:09 mhelaiwa