html-webpack-plugin output html , interior body empty

Created on 22 Mar 2017  路  4Comments  路  Source: jantimon/html-webpack-plugin

use html-webpack-plugin output html page , but in output page lost body inner html element , like <div id="app"></div> , here is my input output and webpack.config file :

input

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
        <link rel="icon" href="static/pic/logo.png" type="image/x-icon">
        <link rel="stylesheet" href="static/weui/weui.min.css">
        <link rel="stylesheet" href="static/index.css">
        <title>APP</title>
    </head>
    <body>
        <div id="app"></div>
        <script src="./dist/vendor.js"></script>
        <script src="./dist/app.js"></script>
    </body>
    </html>

output

    <!DOCTYPE html>
    <html>
      <head>
        <meta charset="UTF-8">
        <title>SPA</title>
      <link href="/dist/style.df241090c6a9e0a6bf26.css" rel="stylesheet"></head>
      <body>
      <script type="text/javascript" src="/dist/vendor.df241090c6a9e0a6bf26.js"></script><script type="text/javascript" src="/dist/app.df241090c6a9e0a6bf26.js"></script></body>
    </html>

part webpack.config.js

    const htmlWebpackPlugin = require('html-webpack-plugin');

        plugins: [
            new htmlWebpackPlugin({
                title:'SPA',
                filename: 'assets/index.html'
            })
        ],

Most helpful comment

I believe you have to specify the template option to your index file (or template file if using a templating engine) otherwise htmlwebpackplugin will default to its own.

All 4 comments

I believe you have to specify the template option to your index file (or template file if using a templating engine) otherwise htmlwebpackplugin will default to its own.

@Squidies yes , i fixed it , thanks

fixed #622

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

azat-io picture azat-io  路  4Comments

mmjamal picture mmjamal  路  3Comments

var-bp picture var-bp  路  3Comments

ghaiklor picture ghaiklor  路  3Comments

lcxfs1991 picture lcxfs1991  路  4Comments