Read file contents at build time via babel-plugin-macros, similar to webpack raw-loader
Clone or download
greenkeeper[bot] and pveyes Update microbundle to the latest version 🚀 (#12)
* chore(package): update microbundle to version 0.7.0

* chore(package): update lockfile yarn.lock
Latest commit ac7cc89 Oct 27, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src init Feb 17, 2018
.babelrc init Feb 17, 2018
.gitignore init Feb 17, 2018
.prettierrc init Feb 17, 2018
.travis.yml Update to node 10 in .travis.yml (#6) May 8, 2018
LICENSE init Feb 17, 2018
README.md babel macro badge Feb 19, 2018
package.json Update microbundle to the latest version 🚀 (#12) Oct 27, 2018
yarn.lock Update microbundle to the latest version 🚀 (#12) Oct 27, 2018

README.md

raw.macro

Build Status Babel Macro Greenkeeper badge

Webpack raw-loader implemented as babel-plugin-macros

Usage

Similar to nodejs require call:

import raw from "raw.macro";

const markdown = raw("./README.md");

Why

I came across a few problem when using raw-loader in create-react-app.

  • I need to use webpack loader syntax (which needs to be disabled via eslint).
  • Some newlines are removed unintentionally.

This can also be useful in environment where webpack is not available / not extensible. Just use babel and you're good to go.

License

MIT