forked from pixijs/assetpack
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
57 changed files
with
880 additions
and
568 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
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 |
---|---|---|
@@ -1,27 +1,109 @@ | ||
--- | ||
sidebar_position: 1 | ||
sidebar_position: 0 | ||
--- | ||
|
||
# Configuration | ||
# API Reference | ||
|
||
AssetPack uses a config file to define what assets you want to optimise and how you want to optimise them. The config file is a JavaScript file that exports an object with the following properties: | ||
|
||
- `entry`: The directory where your raw assets are located. | ||
- `output`: The directory where you want your optimised assets to be outputted to. | ||
- `plugins`: An object containing the plugins you want to use. The key is the name of the plugin, and the value is the plugin itself. | ||
- `ignore`: an optional array of ignore patterns. Any file path matching the patterns will not be processed by assetpack | ||
- `cache`: an optional boolean to enable or disable caching. Defaults to true. | ||
- `logLevel`: an optional string to set the log level. Defaults to 'info'. | ||
- `files`: an optional object to override the settings and tags of any assets. See [Config Overrides](#config-overrides) for more details. | ||
### entry | ||
|
||
| Type | Default | Required | | ||
| -------- | ------- | -------- | | ||
| `string` | | Yes | | ||
|
||
The directory where your raw assets are located. | ||
|
||
### output | ||
|
||
| Type | Default | Required | | ||
| -------- | ------- | -------- | | ||
| `string` | | Yes | | ||
|
||
The directory where you want your optimised assets to be outputted to. | ||
|
||
### ignore | ||
|
||
| Type | Default | Required | | ||
| ---------- | ------- | -------- | | ||
| `string[]` | | No | | ||
|
||
An optional array of ignore patterns. Any file path matching the patterns will not be processed by assetpack. | ||
|
||
### cache | ||
|
||
| Type | Default | Required | | ||
| --------- | ------- | -------- | | ||
| `boolean` | `true` | No | | ||
|
||
An optional boolean to enable or disable caching. | ||
|
||
### cacheLocation | ||
|
||
| Type | Default | Required | | ||
| -------- | -------------- | -------- | | ||
| `string` | `'.assetpack'` | No | | ||
|
||
An optional string to set the location of the cache. | ||
|
||
### logLevel | ||
|
||
| Type | Default | Required | | ||
| -------- | -------- | -------- | | ||
| `string` | `'info'` | No | | ||
|
||
An optional string to set the log level. | ||
|
||
### pipes | ||
|
||
| Type | Default | Required | | ||
| -------- | ------- | -------- | | ||
| `Pipe[]` | | No | | ||
|
||
An array of pipes to use. For examples of pipes, see [Pipes](/docs/guide/pipes/overview#concepts). | ||
|
||
### assetSettings | ||
|
||
| Type | Default | Required | | ||
| ---------------- | ------- | -------- | | ||
| `AssetSetting[]` | | No | | ||
|
||
| Property | Type | Default | Required | | ||
| -------- | -------- | ------- | -------- | | ||
| files | `string` | | Yes | | ||
| settings | `object` | | No | | ||
| metaData | `object` | | No | | ||
|
||
An optional array of asset settings. This allows you to set specific settings for individual assets. | ||
|
||
#### Example | ||
|
||
```js | ||
// .assetpack.js | ||
|
||
export default { | ||
entry: "./raw-assets", | ||
output: "./public", | ||
plugins: {}, | ||
entry: './raw-assets', | ||
output: './public', | ||
ignore: ['**/*.html'], | ||
cache: true, | ||
cacheLocation: '.assetpack', | ||
logLevel: 'info', | ||
pipes: [ | ||
// Pipes go here | ||
], | ||
assetSettings: [ | ||
{ | ||
files: ['**/*.png'], | ||
settings: { | ||
compress: { | ||
jpg: true, | ||
png: true, | ||
// all png files will be compressed to avif format but not webp | ||
webp: false, | ||
avif: true, | ||
}, | ||
}, | ||
}, | ||
], | ||
}; | ||
``` |
This file was deleted.
Oops, something went wrong.
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,68 @@ | ||
--- | ||
sidebar_position: 4 | ||
title: Github Action | ||
--- | ||
|
||
# Github Action | ||
|
||
:::info | ||
You must enable `cache` in your assetpack configuration to use this feature. | ||
|
||
See [API Reference](/docs/guide/configuration#cache) for more information. | ||
::: | ||
|
||
AssetPack can be used with GitHub Actions to automate the asset optimisation process and cache the result, improving build times. This guide will show you how to set up a GitHub Action to run AssetPack on your repository. | ||
|
||
## Setup | ||
|
||
To set up a GitHub Action for AssetPack, you need to create a new workflow file in your repository. Create a new file in the `.github/workflows` directory with the following content: | ||
|
||
:::note | ||
This example assumes that your raw assets are located in a directory called `raw-assets` and that you have a `build` script in your `package.json` file that runs AssetPack. | ||
|
||
You may need to adjust the paths and commands to match your project structure. | ||
::: | ||
|
||
```yaml | ||
name: AssetPack | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20' | ||
|
||
- name: Install dependencies | ||
run: npm ci | ||
|
||
# Cache assets! | ||
- name: Generate hash from file names | ||
id: hash-names | ||
run: echo "NAMES_HASH=$(find ./raw-assets -type f | sort | md5sum | cut -d' ' -f1)" >> $GITHUB_ENV | ||
|
||
- name: Cache .assetpack directory | ||
id: cache-directory | ||
uses: actions/cache@v4 | ||
with: | ||
path: | | ||
.assetpack | ||
raw-assets | ||
key: ${{ runner.os }}-cache-23-04-24-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('raw-assets/**/*') }}-${{ env.NAMES_HASH }} | ||
restore-keys: | | ||
${{ runner.os }}-cache-23-04-24-${{ hashFiles('**/package-lock.json') }} | ||
# End Cache assets! | ||
|
||
# Now do your build | ||
- name: Build | ||
run: npm run build | ||
``` | ||
Oops, something went wrong.