vbenjs / vite-plugin-html

A vite plugin for processing html. It is developed based on lodash template
MIT License
582 stars 93 forks source link

多页面模式下不同页面的template有办法用同一个html吗 #51

Open 1SZX1 opened 2 years ago

John-Soul commented 2 years ago

try this. createHtmlPlugin({ minify: hasBuild, entry:src/views/${project[projectName].viewsPath}/main.js, template: 'index.html', inject: { data: { htmlData: { options: { appCode: project[projectName].appCode, mainJs:./src/views/${project[projectName].viewsPath}/main.js, } } } } }) <script type="module" src="<%- htmlData.options.mainJs %>"></script>

1SZX1 commented 2 years ago

try this. createHtmlPlugin({ minify: hasBuild, entry:src/views/${project[projectName].viewsPath}/main.js, template: 'index.html', inject: { data: { htmlData: { options: { appCode: project[projectName].appCode, mainJs:./src/views/${project[projectName].viewsPath}/main.js, } } } } }) <script type="module" src="<%- htmlData.options.mainJs %>"></script>

感谢,但是这个方法我之前就试过行不通的,开发时无法进入第二个入口,打包后也只有一个html文件