Hi, I'm wondering if I could do something like moving the pages and components directory from
/
to
/src
From Nuxt.js' source code /lib/webpack/base.config.js file, I saw these directories are defined in the webpack alias.
So in nuxt.config.js file in my project, I override these alias like:
var projectSrc = path.join(__dirname, 'src')
module.exports = {
extend(config, ctx) {
// Override
config.resolve.alias['~'] = path.join(projectSrc)
config.resolve.alias['~assets'] = path.join(projectSrc, 'assets')
config.resolve.alias['~components'] = path.join(projectSrc, 'components')
config.resolve.alias['~middleware'] = path.join(projectSrc, 'middleware')
config.resolve.alias['~pages'] = path.join(projectSrc, 'pages')
config.resolve.alias['~plugins'] = path.join(projectSrc, 'plugins')
}
}
But I got this error while trying to run npm run dev:
Couldn't find a `pages` directory. Please create one under the project root
Have a look at https://nuxtjs.org/api/configuration-srcdir/#the-srcdir-property.
Thanks! Could not believe I missed that out!
No problem!
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
Have a look at https://nuxtjs.org/api/configuration-srcdir/#the-srcdir-property.