Closed thescientist13 closed 6 years ago
Error: Plugin could not be registered at 'html-webpack-plugin-before-html-processing'. Hook was not found.
BREAKING CHANGE: There need to exist a hook at 'this.hooks'. To create a compatiblity layer for this hook, hook into 'this._pluginCompat'.
at Compilation.plugin (/***/node_modules/tapable/lib/Tapable.js:63:9)
at Compilation.deprecated [as plugin] (internal/util.js:52:15)
at /***/node_modules/webpack-pwa-manifest/dist/index.js:55:21
Hey @FDiskas , just a heads up I think you might have meant to comment in a different PR (for webpack-contrib/html-webpack-plugin)? Or if you did mean this one, could you please elaborate? Just keep in mind this PR for upgrading our application is still heavily WIP (work in progress) though I have been documenting it extensively so as to provide a guide to others doing the same.
Hope that helps you out βοΈ
@thescientist13 yes you are right. Sorry :v: :
no worries @FDiskas , hope you're able to get your issued resolved β
Final stats, all running locally (so no gzip, HTTP/2 etc) for getting a general feel of what things look like before / after the upgrade.
2 assets
4 modules
β¨ Done in 44.71s.
Asset Size Chunks Chunk Names
bbf1e3879689c911d25a8ebddb4d8f76.otf 13.9 KiB [emitted]
bc517149950afc2999fdec6f2e1bf064.otf 14.3 KiB [emitted]
Entrypoint mini-css-extract-plugin = *
5 modules
β¨ Done in 29.08s.
All metrics improved through this upgrade in particular build time just running locally, deploying this in the wild should bring even more improvements !! π
What's really compelling is although the network request size stayed the same, much less code was shipped down to the user which can seem to be correlated to the increase in Lighthouse score boost in the performance rating.
webpack is really packing that JavaScript π
I think this change plus lazy loading the blog posts details route will really make big improvements to performance
@DevLab2425 mind taking a look?
@thescientist13 Just finding the time to dig in, and first let me say I'm no Webpack expert, nor a PWA expert, I just play one on ~TV~ a daily basis.
Looking at your prod build I see a few slight differences from mine, but the majority looks similar to mine. (Considering I used this repo as a Webpack reference, there's no surprise there.)
A few things I have, that you do not:
A few thing you have, that I do not:
You're using both the FaviconsWebpackPlugin
and WebpackPwaManifest
to generate icons. This actually generates too many, IMO. I've configured the 2 to play nice together. My relevant options look like:
WPM icons array:
icons: [
{
src: path.resolve('./src/assets/img/favicon-32x32.png'),
sizes: [40, 48, 58, 60, 72, 80, 87, 120, 152, 180, 167, 512],
destination: path.join('./', 'assets', 'icons'),
ios: true
},
{
src: path.resolve('./src/assets/img/favicon-32x32.png'),
size: 1024,
destination: path.join('./', 'assets', 'icons'),
ios: 'startup'
}
]
FWP icons object:
prefix: 'assets/icons/',
icons: {
android: true,
appleIcon: false,
appleStartup: false,
coast: false,
favicons: true,
firefox: true,
opengraph: true,
twitter: true,
yandex: false,
windows: false
}
Hope this helps.
thanks for the set of eyes on this @DevLab2425 !! π π
I'm using multiple entry files, you have a single. This gives me smaller assets in hopes of avoiding blocking scripts
This is intentional and is considered best practice now in webpack now that CommonsChunkPlugin is deprecated and there is the optimization
configuration option (which I am using in webpack.config.prod.js).
In reviewing the linked gist from that tweet, I've actually removed the cacheGroup
setting since vendor is already a default group.
My local benchmark testing seems to corroborate that this recommended approach leads to an overall improvement as I saw one less HTTP request for JavaScript and smaller bundle size, so I would recommend you give it a shot too and let me know what your results look like! βοΈ
I have a minified CSS file injected into index.html. You seem to still have the multiple CSS file issue
Hmm, anyway you could share your config files with me? (maybe a 1:1 DM on slack)
You're using both the FaviconsWebpackPlugin and WebpackPwaManifest to generate icons.
Good call. Any thoughts on just dropping FaviconsWebpackPlugin
altogether?
@DevLab2425 I think I've got #139 resolved now. Current production config
const commonConfig = require('./webpack.config.common');
const FaviconsWebpackPlugin = require('favicons-webpack-plugin');
const HtmlCriticalPlugin = require('html-critical-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const path = require('path');
const WebpackPwaManifest = require('webpack-pwa-manifest');
const webpack = require('webpack');
const UglifyJsWebpackPlugin = require('uglifyjs-webpack-plugin');
const webpackMerge = require('webpack-merge');
module.exports = webpackMerge(commonConfig, {
mode: 'production',
optimization: {
minimizer: [
new UglifyJsWebpackPlugin(),
new OptimizeCssAssetsPlugin({
cssProcessorOptions: { discardComments: { removeAll: true } }
})
],
splitChunks: {
chunks: 'all',
cacheGroups: {
styles: {
name: 'styles',
test: /\.css$/,
chunks: 'all',
enforce: true
}
}
}
},
module: {
rules: [{
test: /\.(s*)css$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
'sass-loader'
]
}]
},
plugins: [
new FaviconsWebpackPlugin({
logo: './components/bootstrap/images/pvd-geeks-logo.png',
emitStats: true,
prefix: 'icons/',
statsFilename: 'icons/stats.json',
inject: true,
title: 'Providence Geeks',
background: '#bcbfc2',
icons: {
android: true,
appleIcon: false,
appleStartup: false,
coast: false,
favicons: true,
firefox: true,
opengraph: true,
twitter: true,
yandex: false,
windows: false
}
}),
new WebpackPwaManifest({
name: 'Providence Geeks',
short_name: 'PVD Geeks', // eslint-disable-line camelcase
start_url: '.', // eslint-disable-line camelcase
inject: true,
fingerprints: true,
ios: true,
background_color: '#bcbfc2', // eslint-disable-line camelcase
theme_color: '#1a2930', // eslint-disable-line camelcase
icons: [{
src: path.resolve('./src/components/bootstrap/images/pvd-geeks-logo.png'),
sizes: [40, 48, 58, 60, 72, 80, 87, 120, 152, 180, 167, 512],
ios: true
}, {
src: path.resolve('./src/components/bootstrap/images/pvd-geeks-logo.png'),
size: 1024,
ios: 'startup'
}]
}),
new MiniCssExtractPlugin({
filename: '[name].[contenthash].css',
chunkFilename: '[id].[contenthash].css'
}),
new HtmlCriticalPlugin({
base: path.resolve(__dirname, 'build'),
src: 'index.html',
dest: 'index.html',
inline: true
}),
new webpack.optimize.ModuleConcatenationPlugin()
]
});
Related Issue
resolves #141
bonus: was able to resolve #139 as well.
Summary of Changes
Upgrade to webpack v4
CommonsChunkPlugin
optimization
configurationdevelopment
andproduction
modesoptimization
configurationDefinePlugin
devDependencies
Stats
So could be potentially be a 50% savings even with another 15s of headroom. pretty nice! π π
But obviously without
ExtractTextWebpackPlugin
, our JS bundles are rather largeTODO
tapable
locally to appease fork of html-weboack-plugin. Update: resolved in webpack-contrib/html-webpack-plugin . Update: upstream has released a compat versioneslint-loader
, it's not supported with v4. Update: resolved in 2.0.0 releaseExtractTextWebpackPlugin
, it is awaiting support for v4. Trying outMiniCssExtractPlugin
- ran into this issue https://github.com/webpack-contrib/mini-css-extract-plugin/issues/50FaviconsWebpackPlugin
, it needs help getting support for v4WebpackPwaManifest
plugin, I opened an issue inquiring about support for v4 . Update: this issue seems to be tracking the release.HtmlCriticalWebpackPlugin
, likely because ofExtractTextWebpackPlugin
but opened a PR to inquire about general webpack v4 support needed. Opened a PR to upgrade the plugin to webpack v4OptimizeCssAssetsPlugin
left in but not sure if it's not running becauseExtractTextWebpackPlugin
is not enabled, but opened a PR to inquire about general webpack v4 support needed.