Back to results
giorgi94/rollup-plugin-astext(opens in a new tab)
Language: JavaScript
Import file as string
- stars
- 0
- watchers
- 1
- forks
- 0
- open issues
- 0
- Last updated
- 08/19/2019
Language: JavaScript
Import file as string
This plugin enables to import files, such as .json or .svg, as string variables.
$ npm install git+https://github.com/giorgi94/rollup-plugin-astext.git
// rollup.config.js import astext from 'rollup-plugin-astext'; export default { input: './src/index.js', plugins: [ astext({ extensions: [".json", ".svg"] // default [".json"] }) ], };
An optional extensions array with file extensions tells which imports should be imported as plain text.
// data.json { "a": 8 } // index.js import data from "./data.json"; console.log(data) /* data -> '{ "a": 8 }' */