Using the html-webpack-plugin plug-in to start the page can put the html page into memory to increase the page loading speed and automatically set the path of the JS file introduced in the index.html page Prerequisite: Webpack is installed in the project. Steps: Step 1. Enter Step 2 : Modify the configuration file of webpack.config.js after the plug-in is installed Import the html-webpack-plugin plug-in in the configuration file and configure the template page path and the generated page name. const path = require("path") // Import html-webpack-plugin const htmlWebpackPlugin = require("html-webpack-plugin") module.exports={ entry:path.join(__dirname,"./src/main.js"), output:{ path:path.join(__dirname,"./dist"), filename:"bundle.js" }, //Configure plugin nodes plugins:[ // Create html-webpack-plugin plugin new htmlWebpackPlugin({ // Set parameters template:path.join(__dirname,"./src/index.html"), // Specify the template page to generate the page in memory according to the specified page filename:"index.html" // Specify the name of the generated page in memory }) ] } After using the html-webpack-plugin plug-in, there is no need to manually process the reference path of bundle.js because the correct path of bundle.js has been automatically introduced in the generated HTML page in memory. Summary - What plugins do: 1. Automatically generate a page in memory based on the specified page 2. Automatically introduce the packaged bundle.js into the page This is the end of this article about the tutorial on how to use the html webpack plugin. For more information about the html webpack plugin, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope you will support 123WORDPRESS.COM in the future! |
<<: How to set MySQL foreign keys for beginners
>>: Nginx rtmp module compilation arm version problem
We all know that the underlying data structure of...
Recently, I need to package the project for membe...
nginx is our most commonly used server, often use...
The ECS cloud server created by the historical Li...
1. HTML font color setting In HTML, we use the fo...
Table of contents Function Introduction Rendering...
This article describes the usage of MySQL stored ...
This article shares the specific code for JavaScr...
Table of contents Date Object Creating a Date Obj...
Method 1: Use the lsb_release utility The lsb_rel...
Usually in project development, we have to deal wi...
Separate the front and back ends and use nginx to...
In fact, it is very simple to achieve this effect,...
1. Scenario description: Our environment uses mic...
closure service nginx stop systemctl stop nginx s...