specify the location of the assets inject to?
In my opinion, the template decides the main layout for the .html documents that created.
so,
if the HtmlWebpackPlugin providers an especial mark (e.g <!-- webpack:javascript -->) in the template, and then replace the <script> tags all here. Now, I think the development experience will be much better!
Therefore, I can code my templates like this:
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8" />
<title>title</title>
<!-- webpack:css -->
<script type="text/javascript">
var F = {
// global config here.
};
</script>
</head>
<body>
<div class="loading"></div>
<div class="app"></div>
<!-- webpack:javascript -->
<script type="text/javascript">
// post logic here
</script>
</body>
</html>
this won't solve all use cases so just turn off injection and add the assets by yourself using the template variables
Er! I got it, I agree with u. Maybe template engine would work well.
Just to help others who find this.
Use this to specify the place of the output in your template:
<% for (var chunk in htmlWebpackPlugin.files.chunks) { %>
<script src="<%= htmlWebpackPlugin.files.chunks[chunk].entry %>"></script>
<% } %>
From https://github.com/jaketrent/html-webpack-template/blob/86f285d5c790a6c15263f5cc50fd666d51f974fd/index.html
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.