Skip to content

Wildcard not matched, instead simply outputted in template #19

@kroko

Description

@kroko

Hi,

I have a setup very similar to first example in the docs

  • File calledpreflight.js exists and that is not (and should be not) added in webpack entry.
  • It is copied to webpack configs output path using copy-webpack-plugin. On the way it receives hashing for filename itself which will change only when contents change.
  • I am using html-webpack-plugin to generate template, i this example auto injecting default one.
  • Accordingly to docs I specify minimatch ready string preflight.*.js which would match stuff in webpack's output path (in my case path: path.join(__dirname, 'public/assets'))

I tried both

  • **/*preflight.*.js
  • preflight.*.js

My test config is

// this copies file from 'src/preflight.js to public/assets/preflight.hash.js
config.plugins.push(new CopyWebpackPlugin([
  {
    from: 'src/preflight.js',
    to: `[name].[hash].[ext]`
  }
]));

config.plugins.push(new HtmlWebpackPlugin({
  title: `TEST`,
  filename: `${path.join(__dirname, 'public')}/index.html`,
  inject: true,
  hash: false,
  cache: true,
  showErrors: true,
  chunksSortMode: 'auto',
  excludeChunks: [],
  xhtml: false,
  alwaysWriteToDisk: true,
  minify: false
}));

config.plugins.push(new HtmlWebpackHarddiskPlugin());

config.plugins.push(new HtmlWebpackIncludeAssetsPlugin({
  assets: [
    'preflight.*.js'
  ],
  append: false,
  hash: false
}));

Template output (prod build, not devserver) is

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>TEST</title>
  <link href="//webpacktest-codesplitting.test/assets/site.3c550d0e6ef1b0cc4345.css" rel="stylesheet"></head>
  <body>
<script type="text/javascript" src="//webpacktest-codesplitting.test/assets/preflight.*.js"></script><script type="text/javascript" src="//webpacktest-codesplitting.test/assets/manifest.27fead361ac3388ca95d.js"></script>
<script type="text/javascript" src="//webpacktest-codesplitting.test/assets/vendor.d52f339f6cf1da9e710d.js"></script>
<script type="text/javascript" src="//webpacktest-codesplitting.test/assets/site.3c550d0e6ef1b0cc4345.js"></script>
</body>
</html>

Whatever I put into assets key is outputted as is within template. As you can see from sourcefile name I am testing code splitting 😄 . Disabling that does not change anything.

What am I missing? Did I overlook the docs and there is no actual minimatching against real files in filesystem that are copied over to output path?

Thanks!

software version(s)
node 8.9.4
npm 5.6.0
Operating System macOS 10.13.2
Webpack 3.10.0
copy-webpack-plugin 4.3.1
html-webpack-plugin 2.30.1
html-webpack-harddisk-plugin 0.1.0
html-webpack-include-assets-plugin 1.0.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions