vuejs / vuepress

📝 Minimalistic Vue-powered static site generator
https://vuepress.vuejs.org
MIT License
22.5k stars 4.77k forks source link

Installing plugin and renaming index.html - plugin doesn't seem to work / load. #2575

Open hvitis opened 4 years ago

hvitis commented 4 years ago

Hello

I am trying to create custom plugin that uses vuepress-html-webpack-plugin. The goal is to rename the final index.html file to test.html. I need it for NGINX and Django&Gunicorn hosting.

const HtmlWebpackPlugin = require("html-webpack-plugin");

module.exports = {
    entry: "index.js",
    output: {
        path: __dirname + "/build",
        filename: "index_bundle.js"
    },
    template:
        "~/repo/build/test.html",
    plugins: [new HtmlWebpackPlugin()]
};

The plugin doesn't seem to work. The compilation passes through the code and nothing happens with the index.html name. (It can change the folder name but not the file). I've been trying to use chainWebpack:

const HtmlWebpackPlugin = require("html-webpack-plugin");

module.exports = {
    chainWebpack: config => {
        config.plugin("html").tap(args => {
            args[0].template =
                "/Users/hvitis/Programming/FullStack/venvToBePrint3D.com/ToBePrint3D/test/test.html";
            return args;
        });
    },
};

but I'm getting:

error vuepress-plugin-anonymous-b4e05e02 apply chainWebpack failed.
Error: Cannot call .tap() on a plugin that has not yet been defined. Call plugin('html').use(<Plugin>) first.

Any idea on how could I load the plugin before tap? Any other ideas on how could I force build process to name index.html differently? Virtualy no other method has worked with VuePress... including ejecting.

Thank you


haoranpb commented 4 years ago

Hi @hvitis , I'm not sure what you're trying to do, but will rename the README.md to test.md work for you?