babel-plugin-transform-file-imports-to-string
v2.0.7
Published
Turn file imports into strings
Downloads
1,619
Readme
- This plugin is fork from babel-plugin-transform-html-import-to-string
babel-plugin-transform-file-imports-to-string
- import any type of files to string in any environment running babel browser / node / react-native
Installation
npm i -D babel-plugin-transform-file-imports-to-string
yarn add -D babel-plugin-transform-file-imports-to-string
Usage
Via .babelrc
or babel.config.js
(Recommended)
.babelrc
{
"plugins": ["transform-file-imports-to-string"]
}
Via CLI
$ babel --plugins transform-file-imports-to-string script.js
Via Node API
require("babel-core").transform("code", {
plugins: ["transform-file-imports-to-string"]
});
Usage Examples
- import html files
<h1>Hello</h1>
Import
import html from '!!file-loader!./example.html';
- import js files as string
const str = 'Hello, World !!';
console.log(str);
Import
import html from '!!file-loader!./example.js';