Skip to content
This repository was archived by the owner on Mar 17, 2021. It is now read-only.
This repository was archived by the owner on Mar 17, 2021. It is now read-only.

Feature: compiler output options support for hash #313

Closed
@aarefiev

Description

@aarefiev

Hi!.

Thanks for great loader. It's really save my time :).

Some days ago I worked on configuring webpack for my own project and I found that I can't use the same output filename settings for all loaders. Especially, for file-loader.

Here is the part of webpack.config.js:

output: {
  path: outputPath,
  filename: '[name].[contenthash].js',
  publicPath: `${publicPath}/`,
  hashDigestLength: 8
},
module: {
  rules: [
    {
      test: /\.(png|jpg|gif|svg|cur)(\?v=\d+\.\d+.\d+)?$/,
      include: paths.src,
      use: [
        {
          loader: 'file-loader',
          options: {
            name: '[name].[hash].[ext]',
            publicPath: `${publicPath}/`
          }
        }
      ]
    }
  ]
},
plugins: [
  htmlWebpackPlugin,
  new MiniCssExtractPlugin({
    filename: '[name].[contenthash].css'
  })
]

After compilation I found that the hash part of name of extracted css and bundled files are truncated, but all other assets that I uploaded as is with file-loader are not. As solution, I should pass maxLength to options.name (in format [name].[hash:8].[ext]) and it will work as I expected.

I think it is not good because I should pass the same settings for each loader. Maybe is better to support compiler settings?
I know that you using loader-utils for process files, that's why I submitted my request there (webpack/loader-utils#120).

I will be glad to hear what you think about it. Thanks :')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions