Vue-cli: Web component demo.html configuration

Created on 27 Apr 2020  路  4Comments  路  Source: vuejs/vue-cli

What problem does this feature solve?

How to configure demo.html content at web component build target?

What does the proposed API look like?

chainWebpack: config => {
        config
            .plugin("html")
            .tap(args => {
                if (process.env.NODE_ENV === "production") {
                    args[0].templateContent = `
<meta charset="utf-8">
<title>room-scheme demo</title>
<script src="https://unpkg.com/vue"></script>
<script src="./room-scheme.js"></script>

<room-scheme data-scheme=${JSON.stringify(data)}></room-scheme>
`
                }
                return args
            })
    }

Most helpful comment

I also want to this feature

All 4 comments

I also want to this feature

me too

You can make it a plugin :)

It can resolve

```js script
const HtmlWebpackPlugin = require("html-webpack-plugin");
const data = require("./src/data.json");

module.exports = {
configureWebpack: {
plugins: [
new HtmlWebpackPlugin({
filename: "demo.html",
minify: false,
templateContent: `

room-scheme demo

`
})
]
}
}

```

Was this page helpful?
0 / 5 - 0 ratings

Related issues

brandon93s picture brandon93s  路  3Comments

chasegiunta picture chasegiunta  路  3Comments

sanderswang picture sanderswang  路  3Comments

OmgImAlexis picture OmgImAlexis  路  3Comments

jgribonvald picture jgribonvald  路  3Comments