enable hmr for index.html when theme files are changed

This commit is contained in:
Reorx 2023-02-07 00:12:05 +08:00
parent 62f5e83afa
commit 3d24551c03
2 changed files with 8 additions and 0 deletions

View File

@ -17,5 +17,12 @@
<div class="cv-container"> <div class="cv-container">
<%- include('src/themes/' + theme + '/index', locals) %> <%- include('src/themes/' + theme + '/index', locals) %>
</div> </div>
<% if (!isProduction) { %>
<!-- import theme ejs to enable HMR -->
<script type="module">
import './src/themes/<%= theme %>/index.ejs'
</script>
<% } %>
</body> </body>
</html> </html>

View File

@ -11,6 +11,7 @@ const outDir = process.env.OUT_DIR || 'dist'
const cvData = require(dataFilename) const cvData = require(dataFilename)
const data = getRenderData(cvData) const data = getRenderData(cvData)
data.theme = process.env.THEME || 'reorx' data.theme = process.env.THEME || 'reorx'
data.isProduction = process.env.NODE_ENV === 'production'
export default defineConfig({ export default defineConfig({