Skip to content

Commit 500ea99

Browse files
Add [pipelinename] to name variables.
1 parent 8028e8b commit 500ea99

File tree

5 files changed

+15
-7
lines changed

5 files changed

+15
-7
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ module.exports = {
115115
pipelines: {
116116
// ...
117117
},
118-
name: '[name]-[contenthash].[ext]',
118+
name: '[name]-[pipelinename]-[contenthash].[ext]',
119119
outputPath: 'images',
120120
esModule: true
121121
// For more options see the file-loader package
@@ -125,4 +125,6 @@ module.exports = {
125125
},
126126
};
127127

128-
```
128+
```
129+
130+
For the name options you can *additionally* use \[pipelinename\]. It will be replaced by the pipeline name or "original" if there is no pipeline defined.

dist/index.js

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export default async function (this:LoaderContext<any>, source: Buffer) {
3232

3333
const defaultOptions = {
3434
pipelines: {},
35-
name: '[name]-[contenthash].[ext]',
35+
name: '[name]-[pipelinename]-[md4:hash:hex:5].[ext]',
3636
outputPath: 'images'
3737
}
3838

@@ -59,6 +59,8 @@ export default async function (this:LoaderContext<any>, source: Buffer) {
5959
format: path.extname(this.resourcePath).replace('.', '')
6060
}
6161
}
62+
63+
options.name = options.name.replace('[pipelinename]', 'original')
6264

6365
let output = await generateOutput(this, resultObj, options)
6466

@@ -83,6 +85,8 @@ export default async function (this:LoaderContext<any>, source: Buffer) {
8385
try {
8486
const resultObj = await sharpInstance.toBuffer({ resolveWithObject: true })
8587

88+
options.name = options.name.replace('[pipelinename]', pipelineName)
89+
8690
output = await generateOutput(this, resultObj, options)
8791

8892
} catch (error) {

0 commit comments

Comments
 (0)