Vue-cil multi-page output to the specified folder

/ / glob is a third-party module that webpack depends on during installation, and the module also allows you to use symbols such as . For example, lib/ .js is the file that gets all the js suffixes under the lib folder
var glob = require ("glob")
var HtmlWebpackPlugin = require (" html-webpack-plugin")
var PAGE_PATH = path.resolve (_ _ dirname,". / src/pages")
var merge = require ("webpack-merge")

/ / Multi-entry configuration
/ / read the js suffix file under all the corresponding folders under the pages folder through the glob module, and treat it as an entry
exports.entries = function () {

if the file exists
/ /.
var entryFiles = glob.sync(PAGE_PATH + "/*/*.js")
var map = {}
entryFiles.forEach((filePath) => {
    var filename = filePath.substring(filePath.lastIndexOf("\/") + 1, filePath.lastIndexOf("."))
    map[filename] = filePath
})
return map

}

/ / Multi-page output configuration
/ / is the same as the above multi-page entry configuration. Read the corresponding html suffix file under the pages folder and put it in the array
exports.htmlPlugin = function () {

.
let entryHtml = glob.sync(PAGE_PATH + "/*/*.html")
let arr = []
entryHtml.forEach((filePath) => {
    let filename = filePath.substring(filePath.lastIndexOf("\/") + 1, filePath.lastIndexOf("."))
    let conf = {
        // 
        template: filePath,
        // 
        filename: filename + ".html",
        // jsjs
        chunks: ["manifest", "vendor", filename],
        inject: true
    }
    if (process.env.NODE_ENV === "production") {
        conf = merge(conf, {
            minify: {
                removeComments: true,
                collapseWhitespace: true,
                removeAttributeQuotes: true
            },
            chunksSortMode: "dependency"
        })
    }
    arr.push(new HtmlWebpackPlugin(conf))
})
return arr

}

according to the above code. This is what happens after packing

clipboard.png

pages

clipboard.png

how do I change the configuration inside?

Sep.16,2021

filename: filePath.replace(/.*[/\\]pages[/\\](.*)\.js/, '$1.html')

conf add path:path.resolve (_ _ dirname, 'dist/filename') to try


landlord. Hello ~ you can refer to the multi-page template based on vue-cli2 that I wrote earlier, portal . I hope it will be helpful to you.

Menu