UNPKG

@amisa/style-plugin

Version:

Transfom css's file to java scripts style element and js to script element

35 lines (31 loc) 1.55 kB
const fs = require('fs') function AmisaCopy(fileName: string, code: string, replaceCallBackFunction: (finaleCode: string) => string, typeIsModule: boolean) { const type = typeIsModule ? 'type="module"' : "", replaced = replaceCallBackFunction ? replaceCallBackFunction(code) : code, freamworkPath = "/Volumes/Users/H.M/source/repos/Hamed228/Amisa.Framework/AmisaMe/AmisaMe.Component/AmisaPackages"; fs.existsSync(freamworkPath) ? fs.writeFileSync( `${freamworkPath}/${fileName}.razor`, `<script ${type} //* ${fileName} *// > //Hi this is amisa, www.amisa.co www.amisa.me emil: amisa@ieee.org ${replaced.replace(/@{1}/gm, "@@")} <\/script>` ) : console.log("razor no", fileName); const mono = "../../../amisa.mono/public", sub = "../../../amisa.sub.mono/public"; function copyMonos(path: any) { fs.existsSync(path) ? fs.writeFileSync( `${path}/${fileName}.js`, `//Hi this is amisa, www.amisa.co www.amisa.me ${fileName} emia: amisa@ieee.org ${replaced}` ) : console.log(fileName, "no"); } copyMonos(mono), copyMonos(sub); } export function AmisaWriteBundle(options: any, bundle: any, replaceCallBackFunction: (finaleCode: string) => string, typeIsModule?: boolean): void { for (const property in bundle) { const { fileName, code } = bundle[property] if (fileName.endsWith('.mjs')) AmisaCopy( fileName.replace('.mjs', ''), code, replaceCallBackFunction, typeof typeIsModule === 'boolean' ? typeIsModule : true ) } }