Skip to content

Use original filename without .gz extension #117

@gilesbutler

Description

@gilesbutler
  • Operating System:
    OSX Mojave 10.14

  • Node Version:
    v8.11.4

  • NPM Version:
    6.8.0

  • webpack Version:
    4.17.1

  • webpack-defaults Version:
    Unknown

Expected Behavior

To be able to use [file] for the filename prop and it return the original filename without the .gz extension

Actual Behavior

There is no output

Code

  {
          filename: "[file]",
          algorithm: "gzip",
          test: new RegExp("\\.(" + productionGzipExtensions.join("|") + ")$"),
          threshold: 0,
          minRatio: 1,
          deleteOriginalAssets: true
    }

As background we're using S3 to host static assets and you have to upload the asset without the .gz extension.

I was trying to use the filename function to hack together what I needed, something like this...

filename(info) {
    // info.file is the original asset filename
    // info.path is the path of the original asset
    // info.query is the query

    // The extension (info.path) is coming through as part of the filename so we need to remove it to get correct filenames for S3
    const filename = info.file.replace(info.path, "");
    return `${filename}.${info.path}`;
},

But then the output folders come out as .js and .css. For some reason they have a proceeding .

Using the filename function and logging the info param I get the following...

  { 
    file: 'js/app.25450252.js',
    path: 'js/app.25450252.js',
    query: '' 
}

Seems like path and file are returning the same thing.

How Do We Reproduce?

You can test it by setting filename: "[file]".

Sorry if I'm missing something blatantly obvious!!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions