update: 扩展内容

This commit is contained in:
ningmengchongshui 2024-06-16 01:26:34 +08:00
parent 574d64205d
commit 48f9f59e5e
2 changed files with 51 additions and 4 deletions

View File

@ -73,4 +73,16 @@ export class Component {
writeFileSync(address, html)
return address
}
/**
* React HTML
* 使
* React HTML
* 使 HTML
*
* SEO
* ReactDOMClient.hydrateRoot()
* React
*/
render = renderToString
}

View File

@ -1,20 +1,55 @@
import { createRequire as cRequire } from 'module'
import path from 'path'
const CustomExtensions = [
//
'.css',
//
'.apng',
'.png',
'.jpg',
'.jpeg',
'.jfif',
'.pjpeg',
'.pjp',
'.gif',
'.svg',
'.ico',
'.webp',
'.avif',
'.mp4',
'.webm',
'.ogg',
'.mp3',
'.wav',
'.flac',
'.aac',
'.opus',
'.mov',
'.m4a',
'.vtt',
'.woff',
'.woff2',
'.eot',
'.ttf',
'.otf'
]
/**
*
* @param basePath
* @param customExtensions ['.css', '.png', '.jpg', '.less', '.scss']
* @param customExtensions
* @returns
*/
export function createRequire(
basePath: string,
customExtensions = ['.css', '.png', '.jpg', '.less', '.scss']
customExtensions = CustomExtensions
) {
const require = cRequire(basePath)
customExtensions.forEach(ext => {
for (const ext of customExtensions) {
require.extensions[ext] = (module, filename) => {
module.exports = path.resolve(filename)
}
})
}
return require
}