naive-ui/build/vite-plugin-index-tranform.js
2024-07-12 02:19:13 +08:00

21 lines
471 B
JavaScript

function transformIndexHtml(code) {
switch (require('node:process').env.NODE_ENV) {
case 'production':
return code.replace(/__INDEX__/, 'demo/index.prod.js')
default:
return code.replace(/__INDEX__/, 'demo/index.dev.js')
}
}
const demoIndexTransFormPlugin = {
name: 'demo-transform',
transformIndexHtml: {
order: 'pre',
handler: (code) => {
return transformIndexHtml(code)
}
}
}
module.exports = demoIndexTransFormPlugin