Import raw plaintext.
$ npm install babel-plugin-macros --save-dev
$ npm install rawquire --save-dev
{
"plugins": ["macros"]
}
Call rawquire
with a file path relative to the current script in the source tree.
Any rawquire
function calls will be replaced with a string literal containing the text from the file.
hello-world.js
:
import { rawquire } from 'rawquire/rawquire.macro';
const myHtml = rawquire('./hello-world.html');
hello-world.html
:
<h1>Hello, world!</h1>
hello-world.js
:
const myHtml = "<h1>Hello, world!</h1>";