1.0.2 • Published 2 years ago
html-webpack-plugin-ignore v1.0.2
html-webpack-plugin-ignore
使 html-webpack-plugin
插件编译时忽略模板中的部分内容。
使用方式
使用 <!-- html-webpack-plugin-ignore-start -->
和 <!-- html-webpack-plugin-ignore-end -->
包裹住不想编译的内容,这两个注释之间的所有内容不会被编译。
- ./index.ejs
<!-- 页面内容部分 start -->
<div class="page">
<!-- 导航栏 start -->
<%- include ./page_body_nav -%>
<!-- 导航栏 end -->
<main>
<!-- html-webpack-plugin-ignore-start -->
<section class="article">
<h1 class="article-title"><%= blogInfo.title %></h1>
<div class="article-info">
<!-- 文章标签 start -->
<% if(blogInfo.tags && blogInfo.tags.length > 0) { %>
<div class="info-tags">
文章标签:
<!-- 遍历标签列表 start -->
<% for(let tag of blogInfo.tags) { %>
<!-- 标签项 start -->
<span class="info-tags-item"><%= tag %></span>
<!-- 标签项 end -->
<% } %>
<!-- 遍历标签列表 end -->
</div>
<% } %>
<!-- 文章标签 end -->
</div>
</section>
<!-- html-webpack-plugin-ignore-end -->
</main>
<!-- html-webpack-plugin-ignore-start -->
<div><%- blogFooterHtml %></div>
<!-- html-webpack-plugin-ignore-end -->
</div>
<!-- 页面内容部分 end -->
- ./page_body_nav
<nav>导航栏</nav>
- 编译后
<div class="page">
<nav>导航栏</nav>
<main>
<section class="article">
<h1 class="article-title"><%= blogInfo.title %></h1>
<div class="article-info">
<% if(blogInfo.tags && blogInfo.tags.length > 0) { %>
<div class="info-tags">
文章标签: <% for(let tag of blogInfo.tags) { %>
<span class="info-tags-item"><%= tag %></span> <% } %>
</div>
<% } %>
</div>
</section>
</main>
<div><%- blogFooterHtml %></div>
</div>