-
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
648307b
commit 2fd9ca7
Showing
18 changed files
with
588 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2021 Jonas Kruckenberg | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
# rollup-plugin-imagetools | ||
|
||
<!-- badges --> | ||
![npm (next)](https://img.shields.io/npm/v/rollup-plugin-imagetools/next) | ||
[![standard-readme compliant](https://img.shields.io/badge/readme%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme) | ||
|
||
A toolbox of import directives for [rollup](https://rollupjs.org) that import and transform your image at compile-time. | ||
All of the image transformations are powered by [sharp](https://sharp.pixelplumbing.com). | ||
|
||
## Features | ||
|
||
- **🚀 Output modern formats** | ||
- **🖼 Resize Images** | ||
- **🔗 Easy Srcset generation** | ||
- **⚡️ Fast in development mode** | ||
- **🔒 Remove Image Metadata** | ||
- **🧩 Extensible** | ||
|
||
> [Read the docs to learn more!](../../docs/README.md) | ||
## Table of Contents | ||
|
||
- [Install](#install) | ||
- [Usage](#usage) | ||
- [Options](#options) | ||
- [Contributing](#contributing) | ||
- [License](#license) | ||
|
||
## Install | ||
|
||
``` | ||
npm install --save-dev rollup-plugin-imagetools@next | ||
``` | ||
|
||
``` | ||
yarn add -D rollup-plugin-imagetools@next | ||
``` | ||
|
||
## Usage | ||
|
||
```js | ||
import { imagetools } from "rollup-plugin-imagetools" | ||
|
||
export default { | ||
plugins: [ | ||
imagetools() | ||
] | ||
} | ||
``` | ||
|
||
```js | ||
import Image from "example.jpg?w=400&h=300&webp" | ||
``` | ||
|
||
## Options | ||
|
||
### include | ||
|
||
• **include**: *string* \| *RegExp* \| (*string* \| *RegExp*)[] | ||
|
||
Which paths to include when processing images. | ||
|
||
**`default`** '**\/*.{heic,heif,avif,jpeg,jpg,png,tiff,webp,gif}?*' | ||
|
||
___ | ||
|
||
### exclude | ||
|
||
• **exclude**: *string* \| *RegExp* \| (*string* \| *RegExp*)[] | ||
|
||
What paths to exclude when processing images. | ||
This defaults to the public dir to mirror vites behavior. | ||
|
||
**`default`** 'public\/**\/*' | ||
|
||
___ | ||
|
||
|
||
### extendTransforms | ||
|
||
• **extendTransforms**: [*Directive*](docs/modules/types.md#transformFactory)<{}\>[] | ||
|
||
You can use this option to extend the builtin list of import directives. | ||
This list will be merged with the builtin directives before applying them to the input image. | ||
See the section [Custom import directives](#custom-import-directives) for details. | ||
|
||
**`default`** [] | ||
|
||
___ | ||
|
||
### extendOutputFormats | ||
|
||
• **extendOutputFormats**: [*OutputFormat*](docs/modules/types.md#outputformat)[] | ||
|
||
You can use this option to extend the builtin list of output formats. | ||
This list will be merged with the builtin output formats before determining the format to use. | ||
See the section [Custom output formats](#custom-output-formats) for details. | ||
|
||
**`default`** [] | ||
|
||
### silent | ||
|
||
• **silent**: *boolean* | ||
|
||
Settings this option to true disables all warnings produced by this plugin. | ||
|
||
**`default`** false | ||
|
||
### removeMetadata | ||
|
||
• **removeMetadata**: *boolean* | ||
|
||
Wether to remove potentially private metadata from the image, such as exif tags etc. | ||
|
||
**`default`** true | ||
|
||
## Contributing | ||
|
||
Feel free to dive in! [Open an issue](https://github.com/JonasKruckenberg/imagetools/issues/new) or submit PRs! | ||
All information to get you started hacking on imagetools is in [CONTRIBUTING.md](../../CONTRIBUTING.md)! | ||
|
||
## License | ||
[MIT © Jonas Kruckenberg.](./LICENSE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
presets: [ | ||
['@babel/preset-env', { targets: { node: '12' }}], | ||
"@babel/preset-typescript" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
testEnvironment: 'node', | ||
collectCoverageFrom: [ | ||
"src/**/*.ts" | ||
] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"name": "rollup-plugin-imagetools", | ||
"version": "0.0.0-next.0", | ||
"main": "dist/index.cjs", | ||
"module": "dist/index.mjs", | ||
"types": "dist/index.d.ts", | ||
"license": "MIT", | ||
"files": [ | ||
"dist" | ||
], | ||
"homepage": "https://github.com/JonasKruckenberg/vite-imagetools/tree/next/packages/vite", | ||
"author": "jkruckenberg <iterpre@protonmail.com>", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/JonasKruckenberg/vite-imagetools.git" | ||
}, | ||
"keywords": [ | ||
"resize-images", | ||
"responsive-images", | ||
"rollup", | ||
"image", | ||
"rollup-plugin" | ||
], | ||
"scripts": { | ||
"dev": "rollup -cw", | ||
"build": "rollup -c", | ||
"test": "jest --config=jest.config.js", | ||
"coverage": "jest --collectCoverage" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "^26.0.22", | ||
"babel-jest": "^26.6.3", | ||
"jest": "^26.6.3", | ||
"jest-file-snapshot": "^0.5.0", | ||
"rollup": "^2.44.0", | ||
"rollup-plugin-typescript2": "^0.30.0", | ||
"typescript": "^4.2.3" | ||
}, | ||
"dependencies": { | ||
"@rollup/pluginutils": "^4.1.0", | ||
"imagetools-core": "^0.1.0-next.11" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import typescript from 'rollup-plugin-typescript2' | ||
|
||
export default { | ||
input: 'src/index.ts', | ||
output: [ | ||
{ | ||
dir: 'dist', | ||
format: 'cjs', | ||
sourcemap: true, | ||
entryFileNames: '[name].cjs', | ||
chunkFileNames: '[name].cjs' | ||
}, | ||
{ | ||
dir: 'dist', | ||
format: 'esm', | ||
sourcemap: true, | ||
entryFileNames: '[name].mjs', | ||
chunkFileNames: '[name].mjs' | ||
} | ||
], | ||
plugins: [ | ||
typescript({ | ||
typescript: require('typescript'), | ||
tsconfigOverride: { | ||
exclude: ['src/**/__tests__/**'] | ||
} | ||
}) | ||
] | ||
} |
3 changes: 3 additions & 0 deletions
3
...ile_snapshots__/rollup-plugin-imagetools-options-include-accepts-a-string-0.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+39.5 KB
packages/rollup/src/__tests__/fixtures/pexels-allec-gomes-5195763.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.