Static GitHub Issues

[920] Can I override Nuxt.js' default directory structure?

prev: Disable ssr, encounter an error when using vue-js-modal
next: Error using coffee-loader as outlined in the docs

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
<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c788">#c788</a>)</em></sub></div>