mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2024-12-09 04:31:35 +08:00
23 lines
578 B
JavaScript
23 lines
578 B
JavaScript
const transformIndexHtml = (code) => {
|
|
switch (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',
|
|
enforce: 'pre',
|
|
// vite build is production will not invoke `transformIndexHtml`
|
|
transform (code, id) {
|
|
if (id.endsWith('.html')) {
|
|
return { code: transformIndexHtml(code), map: null }
|
|
}
|
|
},
|
|
transformIndexHtml
|
|
}
|
|
|
|
module.exports = demoIndexTransFormPlugin
|