KO
|
EN
gitlite — search
Search
#javascript
#python
#hacktoberfest
#react
#ai
#typescript
#llm
#go
#golang
#android
#machine-learning
#rust
#deep-learning
#linux
rollup-plugin-img
★ 26
Open GitHub ↗
rollup-plugin-img
Download README (.md)
Explore Similar Repositories
docker-zeppelin
:
No description available.
pubsub-backup
:
No description available.
Adafruit_MCP3008
:
MCP3008 8-Channel 10-Bit ADC
YHDownLoad
:
tableview中下载任务,多线程,并发,解决重用
jekyll-starter-kit
:
A simple framework for starting your own Jekyll project
// repository documentation
Was this content helpful?
★ 0
(0 ratings)
Select Rating:
★
★
★
★
★
Submit Feedback
Recent Feedback
×
Download README
Do you want to download the
README.md
file for
rollup-plugin-img
?
Download (.md)
# rollup-plugin-img Import image files with rollup. Let you import images just like what you do with webpack in your React code! ## Installation yarn add --dev rollup-plugin-img or npm install -D rollup-plugin-img ## Usage In the rollup.config.js: ```JavaScript 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: ```JavaScript import img from 'path/image.png'; ... render() { return <img src={ img } />; } ... ``` ## Options You can pass an option to the `image()` just like above, and there are some options: - exclude & include: Optional. like other rollup plugins. [Details](https://github.com/rollup/rollup/wiki/Plugins) - output: Required. the dest path of output image files. The first directory of dest will be handled as the base output directory(where the html file will be, usually). - extensions: Optional. a regular expression for the extensions of image files. - limit: Optional. the limit(byte) of the file size. A file will be transformed into base64 string when it doesn't exceeded the limit, otherwise, it will be copyed to the dest path. - hash: Optional. a boolean value to indicate wheather to generate a hash string in file name(default false). demo: ```JavaScript ... 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/**' }) ... ``` ## License MIT