I\'m using node + express and I am just wondering how I can import any file as a string. Lets say I have a txt file all I want is to load it into a variable as such.
To read the CSS file to String, use this code. It works for .txt
.
const fs = require('fs')
const path = require('path')
const css = fs.readFileSync(path.resolve(__dirname, 'email.css'), 'utf8')
ES6:
import fs from 'fs'
import path from 'path'
let css = fs.readFileSync(path.resolve(__dirname, 'email.css'), 'utf8')