bluebeel / now-nuxt

A Now v2 Nuxt builder
25 stars 1 forks source link

with the most basic example only file directory is shown #4

Closed dohomi closed 5 years ago

dohomi commented 5 years ago

Hello, I just tried out your builder but for me the most basic example does not work as expected:

{
  "version": 2,
  "name": "nuxt-storyblok-naturheilpraxis",
  "public": false,
  "builds": [
    {
      "src": "nuxt.config.js",
      "use": "@bluebeel/nuxt"
    }
  ]
}

I only have one index.vue file inside of pages and instead of render the HTML only a file directory is shown: https://nuxt-storyblok-naturheilpraxis-lfiz4w3v2.now.sh/ Is there some configuration missing? This is the configuration part of nuxt.config.js:

srcDir: 'src/',
mode: 'universal',
router: {
    middleware: 'languageDetection',
    extendRoutes (routes, resolve) {
      routes.push({
        name: 'custom',
        path: '/:slug*',
        component: '~/pages/index.vue'
      })
    }
  },
serverMiddleware: [
    '~/server-middleware/server-middleware'
  ],
  render: {
    resourceHints: false,
    http2: {
      push: true
    },
    static: {
      maxAge: '1y'
    }
  },
  modern: 'server'

It seems the index.html file is not being generated by the builder.. only the _nuxt/[*].js files.

Chaoyingz commented 5 years ago

I had the same issue

bluebeel commented 5 years ago

A forgotten on my part in the readme sorry.

You have to add an option in the nuxt.config.js file

build:  {
      filenames: {
        app: '[name].js',
        chunk: '[name].js'
      }
}

I put this option mandatory because i need to determine which output file is app.js, commons.js, runtime.js and files from different pages. So it's much simpler if at the output I have the name of the files rather than a hash.

And don't forget to change the way the object is returned. The default nuxt.config.js is


export default {
  ...
}

To

module.exports = () => {
  return { ... }
}
Chaoyingz commented 5 years ago

@bluebeel Thank you very much!

dohomi commented 5 years ago

@bluebeel could you maybe give a hint at the docs how to configure the routes section of the now.json file? Currently I've seen that you enabled some for the more advanced example, the basic example does not have a routes section. I'm quite confused if its necessary to set up or if I can leave it empty.

bluebeel commented 5 years ago

You must use routes if you manage dynamic routes. This is the difference between the basic and complex example. In the basics, I have 2 "static" paths (/and /about) and the complex, several dynamic path. By default, now does not manage these, so we must help him and tell him which lambda to use for dynamic routes.

The routes section accept regex patterns (PCRE). So if you look at Output from my complex example, you will see that there are 4 lambdas in total.

now uses index as a default since he is there. For other path I use the routes section.

I hope it's clear otherwise as soon as I can I'll do a more complete example to explain what can be done with the routes section.

dohomi commented 5 years ago

@bluebeel I followed your advised. But for me nothing changed, I still only receive a directory listing. Does it has to do that I use a srcDir because thats all I might have differently to your setup. I only have one index.vue file which should receive all incoming requests. I configured nuxt.config.js to forward all requests as you can see above. I added the filenames section inside of the build section but I still receive the same output: https://nuxt-storyblok-naturheilpraxis-e25y5avsw.now.sh

bluebeel commented 5 years ago

@dohomi can you make a public deployment if possible? It's weird you don't even have the pages folder with your index.js output.

Does changing the srcDir also change the output folder of the pages? If yes, it might be the cause.

dohomi commented 5 years ago

@bluebeel Ok I disabled all the personal config and now it built successful. There might be some issues with my config - I will enable step by step and report back which was causing the issue

bluebeel commented 5 years ago

ok open a new issue if needed