When JS/CSS aggrigation/preprocess is enabled, for the gtag.js and gtm.js I get an error: "Only file JavaScript assets with preprocessing enabled can be optimized.".
related to the Drupal 10.2.1.

Issue fork google_tag-3413105

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

nortmas created an issue. See original summary.

nortmas’s picture

StatusFileSize
new519 bytes

I believe it's just a workaround.

eduardo morales alberti’s picture

Same error here

summit’s picture

Hi, will this patch be committed?

namisha jadhav’s picture

StatusFileSize
new544 bytes
anybody’s picture

anybody’s picture

Status: Active » Needs review

I created a MR with the workaround from #5 until the core issue (#3416508: Skip generating aggregates that won't be used for stale asset requests) is resolved.
Basically, the core issue fix will have the same result as using the MR, at least as long as Drupal won't minify JS with preprocess: false.

Semantically the hotfix here is wrong, but technically it's fine.

sircosta’s picture

Same issue confirmed on a Drupal 10.5.4 production site.
The error occurs with JS aggregation enabled, and disabling it resolves the problem.
The workaround of setting { preprocess: true } on gtag.js and gtm.js fixes the issue permanently.

anybody’s picture

Status: Needs review » Closed (works as designed)

This is NOT an issue in google_tag module! It's the linked core issue in combinatin with COOKiES / Klaro module!
See https://www.drupal.org/project/drupal/issues/3416508#comment-16340916 for details.

The attached patch does NOT fix it. So I'll close this one. Having { preprocess: false } WITHOUT , minified: true is totally fine!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.