Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: criticalSrc.indexOf is not a function When Trying to Run Production Build #22

Open
brianrivet-tilt opened this issue Jun 25, 2024 · 0 comments

Comments

@brianrivet-tilt
Copy link

Hi,

I'm trying to use the laravel-mix-criticalcss extension on a site I'm working on that uses Mix for the front end and I'm getting the following error in my build process when it tries to run it:

TypeError: criticalSrc.indexOf is not a function
at /node_modules/laravel-mix-criticalcss/index.js:39:33
at Array.forEach ()
at Critical.webpackPlugins (/buddy/investarstage/node_modules/laravel-mix-criticalcss/index.js:34:30)

Here's my code from my mix file:

.criticalCss({
		enabled: mix.inProduction(),
		paths: {
			base: process.env.PRIMARY_SITE_URL,
			templates: './css/critical', //Where css files need to be written, all these paths are relative to /public
										 //So the example path here will be public/css/critical       
			suffix: '_critical.min'
		},
		urls: [
			{ url: process.env.BASE_URL , template: 'index' },
			{ url: process.env.BASE_URL + 'personal-banking', template: 'personal' },
			{ url: process.env.BASE_URL + 'small-business-banking', template: 'smallbusiness' },
			{ url: process.env.BASE_URL + 'commercial-banking', template: 'commercial' },
			{ url: process.env.BASE_URL + 'about-us', template: 'about' },
			{ url: process.env.BASE_URL + 'locations', template: 'location' },			
		],
		//Now using https://github.com/addyosmani/critical v4.0.1
		options: {
			//It's important to note here you should NOT set inline:true, this will break the whole system.
			
			minify: true,
			dimensions: [
				{
				  height: 700,
				  width: 300,
				},
				{
				  height: 200,
				  width: 500,
				},
				{
				  height: 1024,
				  width: 768,
				},
				{
				  height: 900,
				  width: 1024,
				},
			  ],
			
		},
	})

Can you help me to troubleshoot why this is occurring?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant