Minifying with a Worker

I am creating a Cloudflare worker using webpack.

I have found that I can use ycssmin to minify a CSS file via my Worker.

I am trying to also minify javascript with my Worker. However, I can not seem to use uglify-js with webpack as it is throwing errors.

I also seem to get errors because I am trying to minify HTML as well using

Are there any better minifying options on the fly via webpack or with a Worker in general?

Are you hitting the 1MB code limit?
Webpack should throw warnings above 256Kb, but your bundled code can be 4x that.

production mode minifies by default.

const config = {
  target: "webworker",
  mode: "production",
  entry: "./src/index.js",
  output: {
    path: path.resolve(__dirname, "dist"),
    filename: "main.js"
  performance: {
    hints: 'warning', // enum
    maxAssetSize: 800000, // int (in bytes),
    maxEntrypointSize: 800000, // int (in bytes)

What is your config setup?

My apologies on the confusion.

I am not trying to minify my webpack output. I am trying to get something like UglifyJS packed with webpack so that I can minify javascript on the fly with my worker, but it is not working and I am receiving errors.

Is there a better way or better plugin to use?