-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into chore/cache-buster-name-tweak
- Loading branch information
Showing
173 changed files
with
18,364 additions
and
22,566 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
@play-co:registry="https://npm.pkg.github.com/" |
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
Large diffs are not rendered by default.
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,44 @@ | ||
# @assetpack/plugin-cache-buster | ||
|
||
AssetPack plugin for generating hashes and appending them to the file names. | ||
Super useful for when assets change and they need to be re-downloaded. | ||
|
||
Note that order matters with AssetPack plugins and its best to have this pipe transform happen at. | ||
|
||
When combining this with `texturePacker` you add the `texturePackerCacheBuster` pipe right after | ||
the `cacheBuster` pipe. `texturePackerCacheBuster` will ensure that the json files internanlly update their | ||
asset names to accommodate the new file names. | ||
|
||
## Example transform | ||
|
||
``` | ||
|- assets | ||
|- mySprite.png | ||
|- myJson.json | ||
``` | ||
transforms to: | ||
``` | ||
|- assets | ||
|- mySprite-dfs3e.png | ||
|- myJson-aw3dsf.json | ||
``` | ||
## Installation | ||
|
||
```sh | ||
npm install --save-dev @assetpack/plugin-cache-buster | ||
``` | ||
|
||
## Basic Usage | ||
|
||
```js | ||
import { cacheBuster } from "@assetpack/plugin-cache-buster"; | ||
|
||
export default { | ||
... | ||
pipes: { | ||
... | ||
cacheBuster(), | ||
}, | ||
}; | ||
``` | ||
|
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
1 change: 0 additions & 1 deletion
1
packages/mipmap/rollup.config.mjs → packages/cache-buster/rollup.config.mjs
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 @@ | ||
export * from './cacheBuster'; |
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,49 @@ | ||
import { existsSync } from 'fs-extra'; | ||
import { assetPath, createFolder, getInputDir, getOutputDir } from '../../../shared/test'; | ||
import { cacheBuster } from '../src'; | ||
import { Asset, AssetPack, path } from '@play-co/assetpack-core'; | ||
|
||
const pkg = 'cache-buster'; | ||
|
||
describe('CacheBuster', () => | ||
{ | ||
it('should hash a file', async () => | ||
{ | ||
const testName = 'cache-buster'; | ||
const inputDir = getInputDir(pkg, testName); | ||
const outputDir = getOutputDir(pkg, testName); | ||
|
||
createFolder( | ||
pkg, | ||
{ | ||
name: testName, | ||
files: [ | ||
{ | ||
name: 'ttf.ttf', | ||
content: assetPath(pkg, 'Roboto-Regular.ttf'), | ||
}, | ||
], | ||
folders: [], | ||
} | ||
); | ||
|
||
const assetpack = new AssetPack({ | ||
entry: inputDir, | ||
output: outputDir, | ||
cache: true, | ||
pipes: [ | ||
cacheBuster() | ||
] | ||
}); | ||
|
||
await assetpack.run(); | ||
|
||
const originalPath = path.joinSafe('.testInput', testName, 'ttf.ttf'); | ||
|
||
const asset = new Asset({ | ||
path: originalPath, | ||
}); | ||
|
||
expect(existsSync(path.joinSafe('.testOutput', testName, `ttf-${asset.hash}.ttf`))).toBe(true); | ||
}); | ||
}); |
Binary file not shown.
Oops, something went wrong.