Search code examples
vue.jswebpackvuepress

How to change index.html name in VuePress to book.html


I was trying tons of ideas and documentation, custom plugins, configureWebpack, ChainWebpack configs. Nothing works.

I need to do it from the webpack level because simple renaming the file causes it to loose JS functionalities. The website doesnt work after being build and hosted (despite all the files are being downloaded by the browser and CSS works).

So I need to apply some kind of option of magic in .vuepress folder in config.js in order to obtain an html main file called book.html instead of index.html

(that's for hosting purposes, django & gunicorn, long story)

I would be deeply thankful if somebody would save me days of searching and trying out. Thanks for your time.


Solution

  • Since you have not provided any code sample/snippet I will assume you want to serve contents of /book.html instead of /index.html.

    With this assumption, I propose a workaround using vue-router to redirect all requests to /index.html --> /book.html.

    Here is how you can do it with vuepress. a .vuepress/enhanceApp.js file and define your redirects within it like this:

    export default ({  }) => {
      .addRoutes([
        { path: '/index.html', redirect: '/book.html' }
      ])
    }
    

    you will have both paths active and could use any one of these.