Skip to content
This repository has been archived by the owner on Mar 23, 2019. It is now read-only.

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

Closed
dohomi opened this issue Jan 5, 2019 · 9 comments
Closed

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

dohomi opened this issue Jan 5, 2019 · 9 comments

Comments

@dohomi
Copy link

dohomi commented Jan 5, 2019

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
Copy link

I had the same issue

@bluebeel
Copy link
Owner

bluebeel commented Jan 5, 2019

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
Copy link

@bluebeel Thank you very much!

@bluebeel bluebeel closed this as completed Jan 5, 2019
@dohomi
Copy link
Author

dohomi commented Jan 5, 2019

@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 bluebeel reopened this Jan 5, 2019
@bluebeel
Copy link
Owner

bluebeel commented Jan 5, 2019

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.

  • Index : lambda by default
  • user/_id : the lambda to manage the path user/:id ie: user/123456
  • item/_id : the lambda to manage the path item/:id ie: item/123456 or item/7891234
  • _feed/_page : the lambda to manage the path :feed/:page ie: news/1 or ask/2

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
Copy link
Author

dohomi commented Jan 5, 2019

@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
Copy link
Owner

bluebeel commented Jan 5, 2019

@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
Copy link
Author

dohomi commented Jan 5, 2019

@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
Copy link
Owner

bluebeel commented Jan 5, 2019

ok open a new issue if needed

@bluebeel bluebeel closed this as completed Jan 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants