mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2024-12-21 04:50:14 +08:00
8131aa343c
* chore: migrate to vite2 * styles: remove unsed code * chore: update package.json Co-authored-by: Volankey <jiwen.bai@tusimple.ai>
29 lines
738 B
JavaScript
29 lines
738 B
JavaScript
const transformIndexHtml = (code) => {
|
|
const isTusimple = !!process.env.TUSIMPLE
|
|
switch (process.env.NODE_ENV) {
|
|
case 'production':
|
|
return code.replace(
|
|
/__INDEX__/,
|
|
'/demo/index.' + (isTusimple ? 'ts-prod.js' : 'prod.js')
|
|
)
|
|
default:
|
|
return code.replace(
|
|
/__INDEX__/,
|
|
'/demo/index.' + (isTusimple ? 'ts-dev.js' : '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
|