es-string
v1.0.2
Published
Wrap any file with a JS string and put it in an ES6 module. Originally used to place the contents of a CSS file into any arbitrary HTML document.
Downloads
1
Readme
es-string
Place the contents of any text file in an es6 module.
es-string allows you to easily access and manipulate the contents of any text file by placing them in an es6 module, exported as a string. From here, you can import the string in any other module and manipulate it as you wish.
Why?
Originally, es-string was devised as a way to dynamically insert the contents of a CSS file into any arbitrary HTML document. For instance, if you are writing a browser tool you would like to publish as an npm package but would still like to write your styles as Sass, Less, or plain CSS es-string makes it easy. Simply make es-string a part of your build process, placing the contents of your CSS file in a JavaScript module and dynamically adding them to a tag on page load. This way, you don't have to deal with packaging in CSS files or messy inline styles in JavaScript. Plus, you still have access to the pre-/post- processors you love.
How?
npm install --save-dev es-string
node_modules/.bin/es-string <source file> <destination file>