I'm trying to set up laravel-mix-criticalcss in a Docker container and I'm getting an error. Has anyone come across this before?
Error
[webpack-cli] TypeError: Cannot read property 'content-type' of undefined at temp (/var/www/html/node_modules/critical/lib/file-helper.js:112:37) at /var/www/html/node_modules/critical/lib/file-helper.js:214:27 at runMicrotasks () at processTicksAndRejections (internal/process/task_queues.js:97:5) error Command failed with exit code 2.
webpack.mix.js
let mix = require('laravel-mix');
require('laravel-mix-criticalcss');
mix.sass('resources/assets/sass/style.bundle.scss', 'public/build/css')
.criticalCss({
enabled: mix.inProduction(),
paths: {
base: 'http://localhost',
templates: './',
suffix: '_critical.min'
},
urls: [
{ url: '', template: '/' },
],
options: {
minify: true,
},
});

I had a very similar issue:
and what I found:
https://github.com/addyosmani/critical/issues/414
https://github.com/michtio/laravel-mix-criticalcss/issues/11
so, the problem was
html-critical-webpack-pluginthat used oldcriticalversionI reinstalled
laravel-mix-criticalcssfrom @ampedweb fork: https://github.com/ampedweb/laravel-mix-criticalcssThen I passed production url to plugin's settings
pathes.baseto check if critical css worked.I got new error -
Error: Failed to launch the browser process!I found a troubleshooting url here: https://github.com/puppeteer/puppeteer/blob/master/docs/troubleshooting.md.
Then I installed all recommended libraries from URL above to node container, and now critical CSS works at least for production.
Now I try to figure out with local critical CSS in Docker (I have local error
RequestError: connect ECONNREFUSED 127.0.0.1:8000).