Skip to content

Sourcemaps are not emitted when excluded with deleteOriginalAssets option #215

@ghost

Description

  • Operating System: MacOs Catalina
  • Node Version: 14.15
  • NPM Version: 6.14.8
  • webpack Version: 5.4.0
  • compression-webpack-plugin Version: 6.0.5

Expected Behavior

Sourcemap should be emitted with deleteOriginalAssets when excluded from compression.

Actual Behavior

When deleteOriginalAssets is enabled and map files are excluded from the compression. It is expected that js files are compressed with the same filename and map files are emitted as it is. but the map files are not emitted.

Code

// webpack.config.js
const CompressionPlugin = require('compression-webpack-plugin')
const FileManagerPlugin = require('filemanager-webpack-plugin')

module.exports = {
  mode: 'production',
  devtool: 'source-map',
  plugins: [
    new FileManagerPlugin({
      events: {
        onStart: {
          delete: ['dist/']
        }
      }
    }),
    new CompressionPlugin({
      filename: '[file]',
      exclude: /.map$/,
      minRatio: 10,
      deleteOriginalAssets: true
    })
  ]
}

How Do We Reproduce?

Run webapck with the given config. the dist folder should have a compressed main.js and uncompressed main.js.map, but the map file is not emitted.

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