Wenbo
Wenbo

Reputation: 1452

Webpack output type "var" in production

In webpack 5, when the output of webpack configuration is specified as

output: {
           
            filename: mode === "bundle.js",
            path: "./dist/",
            library: {
                name: "mylib",
                type: "var"
            }
        }

The bundle file generated has the variable named mylib as expected for dev. However, in production, the output variable name mylib is minified as a random letter. I know for production it minified the code by default, that's not a problem. But why is this output name also minified? How do apps use mylib in this case?

Upvotes: 0

Views: 199

Answers (1)

Wenbo
Wenbo

Reputation: 1452

I had

experiments: {
  outputModule: true
}

in my webpack configuration. Removing it and then the "mylib" is not minified.

Upvotes: 3

Related Questions