index.ts 753 B

12345678910111213141516
  1. import fs from 'node:fs';
  2. import path from 'node:path';
  3. const isProduction = process.env.NODE_ENV === 'production';
  4. const dirPath = isProduction ? '.' : '../dist';
  5. const stylesJSFile = fs.readFileSync(path.resolve(__dirname, `${dirPath}/hackmd-styles.js`));
  6. const agentJSFile = fs.readFileSync(path.resolve(__dirname, `${dirPath}/hackmd-agent.js`));
  7. const stylesCSSFile = fs.readFileSync(path.resolve(__dirname, `${dirPath}/style.css`));
  8. // export to app as string
  9. const hackmdFiles = {
  10. stylesJS: stylesJSFile.toString(),
  11. agentJS: agentJSFile.toString(),
  12. stylesCSS: stylesCSSFile.toString().replace(/(\r\n|\n|\r)/gm, ''), // https://stackoverflow.com/questions/10805125/how-to-remove-all-line-breaks-from-a-string
  13. };
  14. export default hackmdFiles;