Html-webpack-plugin: 馃悰 Fail to inject code-splitting script files when webpack 4 optimization.splitChunks.name: false

Created on 3 Mar 2018  路  11Comments  路  Source: jantimon/html-webpack-plugin

Description

As @sokra suggested in one of webpack 4 posts to preserve long term caching:

or switch off name generation via optimization.splitChunks.name: false

html-webpack-plugin somehow fails to inject the generated "splitted" files when I apply this option in combination with output: { filename: '[name].[chunkhash].js' }.

Config

module.exports = {
  mode: 'production',
  output: {
    filename: '[name].[chunkhash].js',
  },
  plugins: [
    new HtmlWebpackPlugin({
      template: './src/index.ejs',
      favicon: './src/favicon.ico',
    }),
  ],
  optimization: {
    splitChunks: {
      chunks: 'all',
      name: false,
    },
    runtimeChunk: true,
  },
};

Template file:

<!DOCTYPE html>
<html>
    <head>
        <title>My App</title>
    </head>
    <body>
        <div id="app"></div>
    </body>
</html>

Relevant Links

Environment

Node.js v8.9.0
darwin 15.6.0
npm 5.5.1
webpack 4.0.1
html-webpack-plugin 3.0.4

Most helpful comment

+1. The same stuff. With

splitChunks: { chunks: 'all', name: false, },

html-wepback-plugin doesn't inject chunks that are not specified as entry points.

All 11 comments

+1

+1. The same stuff. With

splitChunks: { chunks: 'all', name: false, },

html-wepback-plugin doesn't inject chunks that are not specified as entry points.

Any solution?

This happens for us with names on as well, dependent chunks are not included.

any update on this issue? is there a walk around or plan to fix ?

I met this problem too.

+1

+1

+1

Could you please try if this works for you with 4.x alpha?

958

npm i html-webpack-plugin@next

@jantimon Works like a charm. :trumpet::kissing::tada: Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

amorphius picture amorphius  路  3Comments

MatthewKosloski picture MatthewKosloski  路  3Comments

NeverwinterMoon picture NeverwinterMoon  路  3Comments

lcxfs1991 picture lcxfs1991  路  4Comments

GerkinDev picture GerkinDev  路  3Comments