2024-07-12 02:19:13 +08:00
|
|
|
function transformIndexHtml(code) {
|
|
|
|
switch (require('node:process').env.NODE_ENV) {
|
2021-01-12 13:17:26 +08:00
|
|
|
case 'production':
|
2023-12-03 19:51:47 +08:00
|
|
|
return code.replace(/__INDEX__/, 'demo/index.prod.js')
|
2021-01-12 13:17:26 +08:00
|
|
|
default:
|
2023-12-03 19:51:47 +08:00
|
|
|
return code.replace(/__INDEX__/, 'demo/index.dev.js')
|
2021-01-12 13:17:26 +08:00
|
|
|
}
|
|
|
|
}
|
2021-02-17 23:31:56 +08:00
|
|
|
|
2021-01-12 13:17:26 +08:00
|
|
|
const demoIndexTransFormPlugin = {
|
|
|
|
name: 'demo-transform',
|
2023-12-03 19:51:47 +08:00
|
|
|
transformIndexHtml: {
|
|
|
|
order: 'pre',
|
|
|
|
handler: (code) => {
|
|
|
|
return transformIndexHtml(code)
|
2021-01-12 13:17:26 +08:00
|
|
|
}
|
2023-12-03 19:51:47 +08:00
|
|
|
}
|
2021-01-12 13:17:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = demoIndexTransFormPlugin
|