How to use webpack to build a traditional multi-page front-end project (multi-html files)?

single-page applications are built with webpack to enjoy the modern engineering development experience. However, when you encounter a traditional multi-html page project, you will return to the stone age of slash-and-burn cultivation: ES6 cannot be used; css preprocessing languages such as less cannot be used; there is no componentization, and the common part of the page depends on copying and pasting, and you have to change many places as soon as there are changes.

so how should traditional projects with multiple html pages be built in webpack?

in fact, it can mainly solve the two pain points of ES6 and less.

unlike a single-page application, the entry of a traditional multi-page project is html rather than js, and there are multiple. In that case, how to configure webpack? It"s okay to provide an idea.

Feb.14,2022

webpack is not designed for the development of single-page applications, you can also use it to create multi-page applications.

first of all, html-webpack-plugin can solve the generation of multiple pages;
secondly, you can specify different page generation objects by controlling entry and chunks , or you can use multi-compiler to create a configuration object for each page that contains entry and chunks .

you can refer to

I don't think the subject knows exactly what kind of thing webpack is. The problem you are asking is that webpack is going to help you solve it.
to compile es6 to es5, compile to css with babel-loader,less, use less-loader. To get more pages, you need to add more things to the configuration item.
personally, I think that gulp is better, more efficient, and easier to configure for multi-page automated build tools.


to solve the pain points of ES6 and less, ES6 is compiled directly into css with babel,less for reuse.


this plug-in can learn about web-webpack-plugin

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3e18a-2c3cb.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3e18a-2c3cb.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?