Comments (8)
i added example code to the usage section in the readme :)
from metalsmith-sharp.
Got it done with this matcher: **/*(!(*@1x)).@(jpg|jpeg|png)
and doing a second pass with Sharp, but it makes my build process duration jump from couple of seconds to over a minute.
from metalsmith-sharp.
Got the speed back by doing a little tweak, final matcher: **/*(!(*@1x.)+(jpg|jpeg|png))
.
Maybe a similar example matcher should be in the docs? (or then I couldn't figure out the "proper" way to accomplish this)
edit: I guess one could also use the metalsmith-branch
plugin to achieve this.
from metalsmith-sharp.
See the tests here, where I create multiple versions of one image:
https://github.com/axe312ger/metalsmith-sharp/blob/master/test/index.test.js#L168
Alternatively, you can tell the plugin NOT to move files in the first step, so you do another image manipulation different naming. But calling the plugin twice might extend the compile time.
By default, the image is moved, thats why you had to use such a complex matcher.
See here: https://github.com/axe312ger/metalsmith-sharp#movefile
from metalsmith-sharp.
I had disabled moving, the problem was that I didn't know I can do this:
.use(sharp([{
src: '**/*.@(jpg|png|jpeg)',
namingPattern: '{dir}/{name}@1x.jpg',
methods: [{
name: 'resize',
args: [768]
}, {
name: 'toFormat',
args: [ 'jpeg' ]
}],
moveFile: false
}, {
src: '**/*.@(jpg|png|jpeg)',
namingPattern: '{dir}/{name}@2x.jpg',
methods: [{
name: 'resize',
args: [1536]
}, {
name: 'toFormat',
args: [ 'jpeg' ]
}],
moveFile: false
}]))
So, I would add a section to the docs explaining, that to achieve multiple versions of the same files you can give sharp
an array of objects as parameter, instead of only an object.
from metalsmith-sharp.
yes, sure, this is a pretty new feature of the plugin, i missed it in the docs
from metalsmith-sharp.
Nice, that should clear things up!
from metalsmith-sharp.
Also, thanks for a great plugin :)
from metalsmith-sharp.
Related Issues (20)
- An in-range update of cross-env is breaking the build 🚨 HOT 4
- An in-range update of debug is breaking the build 🚨 HOT 1
- An in-range update of babel-core is breaking the build 🚨
- An in-range update of babel-eslint is breaking the build 🚨 HOT 1
- An in-range update of nyc is breaking the build 🚨
- An in-range update of eslint-plugin-standard is breaking the build 🚨 HOT 1
- Link to »minimatch features« in Readme is broken HOT 1
- How to exclude specific files? HOT 13
- An in-range update of sharp is breaking the build 🚨 HOT 4
- An in-range update of semantic-release is breaking the build 🚨 HOT 16
- An in-range update of eslint-plugin-babel is breaking the build 🚨 HOT 1
- How to use resize method with custom options HOT 6
- An in-range update of debug is breaking the build 🚨 HOT 1
- An in-range update of condition-circle is breaking the build 🚨 HOT 1
- The automated release is failing 🚨
- npm install fails HOT 3
- Node 12+ is Unsupported HOT 8
- Merging #next into #master
- Path Separator is Mixed on Windows
- Ability to Specify Sharp Constructor Options
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from metalsmith-sharp.