Basic use of webpack
Modular approach has compatibility issues
But there are some compatibility problems, and the import was not successful, so I used webpack to convert it into incompatible code, and blocked compatibility after conversion.
The development mode will not compress the code
production mode production mode will compress and obfuscate the code
The main.js file is output
main.js has no compatibility
In production mode, the code is compressed
webpack packaging does not cooperate with input and output
By default, the index.html file in the src directory is packaged,
Enter the main directory of the dist directory
Configure the basic use of webpack's automatic packaging function
Note that this bundle.js is a virtual hidden file that exists on disk and is placed in the root directory
Access is to directly enter the address /bundle.js
Configure the preview generation page
(By default, index.html is opened directly without clicking the src directory again)
Copy index.html in src to the root directory, it will open index.html directly
To achieve the above effect, you need to use html-webpack-plugin to generate a preview page (implemented as follows:)
Configure in webpack.config.js
Configure automatic packaging parameters ----- automatically open the browser page configuration after packaging
Note: As long as the configuration file is modified, it needs to be closed and restarted before it can take effect! ! !