amireh / happypack

Happiness in the form of faster webpack build times.
MIT License
4.23k stars 124 forks source link

Happypack corrupts woff/woff2 files #239

Open tomsiwik opened 6 years ago

tomsiwik commented 6 years ago

When I setup my webpack.config.js like the following, everything gets copied with the same size & uncorrupted output correctly:

...
module:{
  rules:{
    //...
    {
        test: /\.(woff|woff2)$/,
        exclude: /node_modules/,
        loader: "file-loader",
        options: {
          name: "[name].[ext]",
          outputPath: "fonts/"
        }
      }
  }
}
...

However, when I change the config to the following, the output in the destination (the fonts) have a wrong size and they can't be loaded in any browser with the message:

Failed to decode downloaded font:

module:{
  rules:{
    //...
    {
        test: /\.(woff|woff2)$/,
        exclude: /node_modules/,
        loader: ["happypack/loader?id=fonts"]
      }
  }
},
...
plugins: [
  new HappyPack({
      id: "fonts",
      threads: 2,
      loaders: [
        {
          loader: "file-loader",
          options: {
            name: "[name].[ext]",
            outputPath: "fonts/"
          }
        }
      ]
    })
]

Please note: this works fine for my svg images. I suspect it has something to do with the raw flag of a loader? String and Buffer missmatching/conversion problems? Hope someone can explain to me what's actually causing this behaviour. Thanks in advance.

Related: #233