Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to work with html-webpack-template #81

Open
bahtou opened this issue Apr 1, 2019 · 0 comments
Open

Failed to work with html-webpack-template #81

bahtou opened this issue Apr 1, 2019 · 0 comments

Comments

@bahtou
Copy link

bahtou commented Apr 1, 2019

Description

I am naming the runtimeChunk as manifest, and using the InlineManifestWebpackPlugin with the string option of the same name: manifest. The webpack config is setup like the following:

optimization: {
    runtimeChunk: {
      name: 'manifest'
    }
},

plugins: [
    new CleanWebpackPlugin(),

    new HtmlWebpackPlugin(htmlTemplate),
    new InlineManifestWebpackPlugin('manifest'),

    new webpack.DefinePlugin({
      'process.env.NODE_ENV': JSON.stringify('production')
    })
]

And the html-webpack template has the inlineManifestWebpackName: 'manifest', defined like the following:

module.exports = {
  // Required
  inject: false,
  template: require('html-webpack-template'),
  // template: 'node_modules/html-webpack-template/index.ejs',

  // Optional
  appMountId: 'root-entry',
  bodyHtmlSnippet: '<custom-element></custom-element>',
  meta: [
    {
      name: 'my App',
      content: 'Something descriptive'
    }
  ],
  mobile: true,
  lang: 'en-US',
  inlineManifestWebpackName: 'manifest',
  title: 'my App'

  // And any other config options from html-webpack-plugin:
  // https://github.com/ampedandwired/html-webpack-plugin#configuration
};

The final HTML file looks like when inject: false:

<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta content="ie=edge" http-equiv="x-ua-compatible">
    <meta name="my App" content="Something descriptive">
    <title>my App</title>
    <meta content="width=device-width, initial-scale=1" name="viewport">
  </head>
  <body>
    <custom-element></custom-element>
    <div id="root-entry">
    </div>
    
    <script src="/build/vendors.0f14.js" type="text/javascript"></script>
    <script src="/build/app.b7d1.js" type="text/javascript"></script>
  </body>
</html>

with inject: true

<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta content="ie=edge" http-equiv="x-ua-compatible">
    <meta name="my App" content="Something descriptive">
    <title>my App</title>
    <meta content="width=device-width, initial-scale=1" name="viewport">
  <meta name="my App" content="Something descriptive"></head>
  <body>
    <custom-element></custom-element>
    <div id="root-entry">
    </div>
    
    <script src="/build/manifest.2902.js" type="text/javascript"></script>
    <script src="/build/vendors.0f14.js" type="text/javascript"></script>
    <script src="/build/app.b7d1.js" type="text/javascript"></script>
  <script type="text/javascript">RUNTIME IS INJECTED HERE</script>
  <script type="text/javascript" src="/build/vendors.0f14.js"></script>
  <script type="text/javascript" src="/build/app.b7d1.js"></script>
</body>
</html>

It's not really clear why inject: false is not working. And in the inject: true I get duplicate files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant