How to inject code into index.html when webpack 4 is packaged

about index.html inject some JS and CSS codes

there are some JS codes, such as responsive and buried point reporting codes, which are directly written into index.html
requirements:
1. Different codes are injected according to the environment, such as
2 is injected in the production environment, and the code is compressed in the production environment

.

what methods have you tried

1. In the webpack3 environment, using asset-inject-html-webpack-plugin
2 and html-webpack-inline-source-plugin will inline all the code

ask for help

is there a feasible solution to the problem of index.html inline code

May.08,2022

this is actually very simple, just use html-webpack-plugin to do it. This plug-in can customize some configuration parameters, and can also support ejs and other template syntax. So you can define a currently running environment variable, that is, development or production. Please refer to the following code for implementation:

1, your related webpack profile

Have you solved the
  

problem? I used node's readline to read the file stream and insert some variables of the backend template into html. You can try

.
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-1b32900-2be08.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-1b32900-2be08.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?