Webpack change module scheme

by default, webpack uses how the Commonjs specification wants to change to AMD or how the CMD specification changes

Jun.29,2022

if you are asking about the output, there are two attributes in output that can control the output specification
1, and the libraryTarget attribute determines how to expose a variable.
default value: libraryTarget: "var", of course, you can also choose
libraryTarget: "amd",
libraryTarget: "commonjs2",
libraryTarget: "umd".

2, how the value of the library attribute
output.library is used varies depending on the value of the output.libraryTarget. The default value of output.libraryTarget is var. If the configuration is as follows:
output: {
library: "myLibrary"
}
if the package result file is introduced using the script tag in the HTML page, then the value of the variable myLibrary will be the return value of the entry file (entry file).

specific you can go to Baidu to use, hope to adopt.

Menu