Skip to content

Commit

Permalink
feat: add rollup integration
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasKruckenberg committed Apr 6, 2021
1 parent 648307b commit 2fd9ca7
Show file tree
Hide file tree
Showing 18 changed files with 588 additions and 8 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@ Whenever you build an something with imagetools-core, make sure to link back to

- Reexport the directives when possible

vite-imagetools reexports all builtin directives, so users can create their own directives using the builtins as building blocks. You should - whenever possible - also do the same so users can profit from the extensible nature of imagetools.
both vite-imagetools and rollup-plugin-imagetools reexport all builtin directives, so users can create their own directives using the builtins as building blocks. You should - whenever possible - also do the same so users can profit from the extensible nature of imagetools.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ A toolbox of easy-to-use import directives that transform and optimize your imag

| Package | Version (click for changelogs)
|------------------------------------------------|:------------------------------------
| [imagetools-core](packages/imagetools-core) | [![vite version](https://img.shields.io/npm/v/imagetools-core/next?label=%20)](packages/imagetools-core/CHANGELOG.md)
| [vite-imagetools](packages/vite) | [![vite version](https://img.shields.io/npm/v/vite-imagetools/next?label=%20)](packages/vite-imagetools/CHANGELOG.md)
| [imagetools-core](packages/imagetools-core) | [![imagetools-core version](https://img.shields.io/npm/v/imagetools-core/next?label=%20)](packages/imagetools-core/CHANGELOG.md)
| [vite-imagetools](packages/vite) | [![vite-imagetools version](https://img.shields.io/npm/v/vite-imagetools/next?label=%20)](packages/vite-imagetools/CHANGELOG.md)
| [rollup-plugin-imagetools](packages/rollup) | [![rollup-plugin-imagetools version](https://img.shields.io/npm/v/rollup-plugin-imagetools/next?label=%20)](packages/rollup-plugin-imagetools/CHANGELOG.md)

## Contributing

Expand Down
2 changes: 1 addition & 1 deletion docs/guide/extending.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Let's break that down:
import { resize, format } from "imagetools"
```

Vite-imagetools exports all directives so you can reuse them in you own directives, as we will see shortly.
Both vite-imagetools and rollup-plugin-imagetools exports all directives so you can reuse them in you own directives, as we will see shortly.

```ts
function customDirective(config, ctx) {
Expand Down
21 changes: 21 additions & 0 deletions packages/rollup/LICENSE
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.
123 changes: 123 additions & 0 deletions packages/rollup/README.md
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)
6 changes: 6 additions & 0 deletions packages/rollup/babel.config.js
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"
]
}
6 changes: 6 additions & 0 deletions packages/rollup/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
testEnvironment: 'node',
collectCoverageFrom: [
"src/**/*.ts"
]
};
43 changes: 43 additions & 0 deletions packages/rollup/package.json
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"
}
}
29 changes: 29 additions & 0 deletions packages/rollup/rollup.config.js
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__/**']
}
})
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 2fd9ca7

Please sign in to comment.