Conversation
packages/imagemin/index.js
Outdated
@@ -0,0 +1,46 @@ | |||
const merge = require('deepmerge'); | |||
|
|||
const imageminLoader = require.resolve('imagemin-webpack/imagemin-loader'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Group the require
s together, and move the resolve
to its own grouping:
const merge = require('deepmerge');
const ImageminWebpackPlugin = require('imagemin-webpack/ImageminWebpackPlugin');
const gifsicle = require('imagemin-gifsicle');
const svgo = require('imagemin-svgo');
const pngquant = require('imagemin-pngquant');
const mozjpeg = require('imagemin-mozjpeg');
const webp = require('imagemin-webp');
const imageminLoader = require.resolve('imagemin-webpack/imagemin-loader');
packages/web/index.js
Outdated
neutrino.use(chunk); | ||
neutrino.use(minify); | ||
|
||
if (options.imagemin) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the goal to switch this to neutrino.options.optimize
when it's available?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but also to pass options if desired, or disable imagemin by passing false.
c961963
to
1a71210
Compare
@eliperelman I rebased this off master. Note: When this is merged into master, there will be a conflict that needs to resolved, as I've moved the This is because we need the imagemin plugin to be applied after the |
packages/imagemin/package.json
Outdated
"image", | ||
"imagemin" | ||
], | ||
"author": "Eli Perelman <eli@eliperelman.com>", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to put your information here since you wrote this package. 😃
670dc52
to
a573e16
Compare
Ok, made those change, plus rebased off master again to mitigate the above mentioned conflicts. |
], | ||
"author": "Tim Kelty <timkelty@gmail.com>", | ||
"license": "MPL-2.0", | ||
"repository": "https://github.com/mozilla-neutrino/neutrino-dev/tree/master/packages/imagemin", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this repo format actually work on npm?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm not sure - I was just following suit with the rest of the middlewares: https://github.com/mozilla-neutrino/neutrino-dev/blob/master/packages/web/package.json#L14
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wtf. When I was viewing this diff, it showed a different format...don't mind me.
Do we know how deterministic the output images files are after being run though minification? It occurred to me that perhaps the process might not be deterministic and thus cause constant hash churn. Continuing on from #446:
To clarify, I don't mean store the Neutrino build directory in the repo. I mean outside the Neutrino build optimise your source directory assets once and commit them, to save the build time penalty every time. I agree one wouldn't want to lose the original Photoshop document or whatever, but normally that would be separate from the file being minimised anyway? |
I think this is a great middleware, and I'll probably end up using it myself in certain projects. I'm just trying to decide whether it would be best for it to be opt-in or opt-out. Knowing impact on build times and image sizes would with calculating a cost-benefit. |
good points, @edmorley.
Not certain. In my experiences the hash's have been the same, but I don't know for sure.
I'd be fine with defaulting |
If we end up making this opt-in instead of opt-out, then there is no value in embedding this into the web middleware. They should just manually add it to their module.exports = {
use: [
'@neutrinojs/react',
'@neutrinojs/imagemin'
]
}; |
@eliperelman good point… I'm fine either way. Maybe leave it out of web until we have a better idea how it will impact builds? |
a573e16
to
36db012
Compare
@eliperelman @edmorley my most recent commit on this PR removes the middleware from web. Reasoning:
|
Sounds good - we can always re-evaluate in the future depending on popularity :-) |
packages/imagemin/README.md
Outdated
module.exports = { | ||
use: [ | ||
['@neutrinojs/imagemin', { | ||
imagemin: {}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation here seems off.
## Customization | ||
|
||
`@neutrinojs/imagemin` creates some conventions to make overriding the configuration easier once you are | ||
ready to make changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we are missing the table of conventions here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a Rules and Plugins table.
packages/web/index.js
Outdated
@@ -192,5 +182,15 @@ module.exports = (neutrino, opts = {}) => { | |||
} | |||
|
|||
config.output.filename('[name].[chunkhash].js'); | |||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this was moved without modification, so we should probably reset this file to what is in master.
packages/imagemin/README.md
Outdated
module.exports = { | ||
use: [ | ||
['@neutrinojs/imagemin', { | ||
imagemin: {}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heh, looks like we may have some mixed tabs in here. Make each indentation here 2 spaces.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh dear…sorry in the middle of changing-editors-hell 🥇
packages/imagemin/package.json
Outdated
"homepage": "https://neutrino.js.org", | ||
"bugs": "https://github.com/mozilla-neutrino/neutrino-dev/issues", | ||
"dependencies": { | ||
"deepmerge": "^2.0.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use deepmerge ^1.5.2
.
🎉 |
Started here: #446
This seemed better suited for a middleware, so that we can apply a single set of imagemin options to both loader assets, as well as any assets written from other plugins (eg copy-webpack-plugin).