You may need an appropriate loader to handle this file type. (Extending Nuxt.js router config)
Closed this issue · 2 comments
jmcmullen commented
When I extend the router through my nuxt.config.js like this:
const router = require(`./routes/${currentRegion}`);
module.exports = {
router: {
...router,
scrollBehavior() {
return { x: 0, y: 0 };
},
},
...
}
I get the following error:
warning in ./routes/nz/faq.vue
Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type.
| <template>
| <section>
| <header>
@ ./routes ^\.\/.*$
@ ./nuxt.config.js
@ ./server/index.js
posva commented
it shouldn't happen since it's just a vue
file. but if you are extracting router options from a dynamic path make it as specific as possible so webpack can figure out exactly the files you are looking after, otherwise, it will try every possible path. One simple solution is putting those files in specific folders. Adding the .js
extension at the end of the required path should also work
jmcmullen commented
Cheers!
Changing it to const router = require(`./routes/${currentRegion}/index.js`);
fixed the problem.