Gem 一覧へ戻る
alwaysonlinetxm/rollup-plugin-img(新しいタブで開きます)
主要言語: JavaScript
rollup-plugin-img
- star 数
- 26
- watcher 数
- 1
- fork 数
- 6
- issue 数
- 4
- 最終更新
- 2018/09/08
主要言語: JavaScript
rollup-plugin-img
Import image files with rollup. Let you import images just like what you do with webpack in your React code!
yarn add --dev rollup-plugin-img
or
npm install -D rollup-plugin-img
In the rollup.config.js:
import image from 'rollup-plugin-img'; export default { entry: 'src/index.js', dest: 'dist/bundle.js', plugins: [ image({ limit: 10000 }) ] };
and in your React code:
import img from 'path/image.png'; ... render() { return <img src={ img } />; } ...
You can pass an option to the image() just like above, and there are some options:
demo:
... image({ output: `${distPath}/images`, // default the root extensions: /\.(png|jpg|jpeg|gif|svg)$/, // support png|jpg|jpeg|gif|svg, and it's alse the default value limit: 8192, // default 8192(8k) exclude: 'node_modules/**' }) ...
MIT