a-r-m-i-n / min Goto Github PK
View Code? Open in Web Editor NEWTYPO3 CMS extension "min" - Compressed CSS, JS and HTML output for TYPO3
TYPO3 CMS extension "min" - Compressed CSS, JS and HTML output for TYPO3
If possible, it would be great if an option/argument for the asset.script viewhelper could be implemented that disables compression of a single asset.
E.g.: <f:asset.script identifier="myScript" src="EXT:sitepackage/Resources/Public/JavaScript/myScript.min.js" compress="false" />
why: some js plugins like "tablefilter js" need a relative "base_path" to their additional resources, which could be wrong if compression is enabled.
Hi,
it seems that during the migration from Bitbucket to GitHub the references in packagist have not been updated. When trying to install 1.7.0 for example I get this error:
The TYPO3 extension package "t3/min", does not define an extension key in its composer.json. Please report this to the author of this package. Specifying the extension key will be mandatory in future versions of TYPO3 (see: https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ExtensionArchitecture/ComposerJson/Index.html#extra)
- Installing t3/min (1.7.0): Downloading Failed to download t3/min from dist: Could not authenticate against bitbucket.org
Now trying to download from source
- Installing t3/min (1.7.0): No bitbucket authentication configured. Falling back to ssh.
Cloning fd6f290b05
No bitbucket authentication configured. Falling back to ssh.
[RuntimeException]
Failed to execute git clone --no-checkout '[email protected]:t--3/min.git' 'redacted/typo3conf/ext/min' && cd 'redacted/typo3conf/ext/min' && git remote add composer '[email protected]:t--3/min.git' && git fetch composer && git remote set-url origin '[email protected]:t--3/min.git' && git remote set-url composer '[email protected]:t--3/min.git'
Cloning into 'redacted/typo3conf/ext/min'...
The requested repository either does not exist or you do not have access. If you believe this repository exists and you have access, make sure you're authenticated.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
While trying to install 1.8.0 works, as it downloads the package from GitHub.
Is this something you can fix? That'd be very appreciated!
Regards
Mattia
It would be better to use Middleware to process
Hi,
the setting is surely meant to be object of configuration. But the ext_typoscript_setup.txt is hard to override. So why not drop the statement at that place to only be set elsewhere or position it in EXT:/min/Configuration/TypoScript/.. ?
Hint: All TS is loaded by EXT:sitepackage/ext_localconf.php or sitepackage/Configuration/TCA/Overrides/sys_template.php
Hello,
I found a bug, when two modules have the same CSS filename there is a conflict with the assetCollector.compressCss
Exemple:
vendor_module1
as main.css
vendor_module2
as main.css
the vendor_module2
CSS will be not rendered with this configuration:
plugin.tx_min.assetCollector {
compressCss = 1
}
when compressCss = 0
, it will work.
In my case I had to change the filename from main.css
to card.css
to avoid this hidden conflict, and have the min-compressed file:
This impact CSS, I didn't check for JS files.
Best,
The current version (v2.1) overwrites global configuration config.compress*
and config.concatenate*
which might often be against the interest of the user, as today's assets are mostly bundled, minified and prepared for long-term caching strategies by other tools.
The documentation already contains the hint to add these yourself: https://docs.typo3.org/p/t3/min/2.1/en-us/Configuration.html#asset-compression-css-js
Including modifications to global config { ... }
together with other, plugin-specific configuration makes it cumbersome to handle complex configuration trees, where global config
is, among other basic settings, configured before extension configuration is included.
I would propose either removing the config
section from the extension TypoScript configuration entirely, or splitting it off into a separate, includable static TypoScript file.
PS: As website author / extension user, not including the provided TypoScript configuration is not a good option either: This raises the maintenance burden, as all relevant non-config
settings need to manually be kept in sync when extension updates introduce new or change existing settings.
This issue did already exist in the forge and bitbucket tracker, but was never fixed.
Now I changed to the recent version and had to adapt my patch.
Example:
in the CSS file generated by TYPO3 there's path like ../../../typo3conf/ext/my_ext/Resources/Public/fonts/myfont.xxx
and the problem is that your extension passes the content of the file to the $minifier->add
method, which results in appending another ../../..
in front of the already correct relative paths (because the source is missing).
The solution is to write the output of compressCss
to a file and pass the file name to $minifier->add
, then the source path is correctly determined by minifier and not changed.
Here's my local patch:
+++ Classes/Minifier.php
@@ -121,7 +121,8 @@
$minifier = new $minifierClassName();
if ($type === self::TYPE_STYLESHEET) {
$minifier->setImportExtensions([]);
- $minifier->add($this->compressCss(file_get_contents($config['file'])));
+ file_put_contents($pathSite . 'tmp' . $targetFilename, $this->compressCss(file_get_contents($config['file'])));
+ $minifier->add($targetFilename);
} else {
$minifier->add($config['file']);
}
Hello,
could you create a new tag so that we get this fix: 4966c4c
and prevent deprecation warnings?
Thank you very much!
When fonts are preloaded in HTML, they are stored in /_assets/XYZ/font.woff2. But when compressing CSS it is stored inside /typo3temp/assets/compressed.
Now with a relative path inside the CSS we would like to hit the folder "/_assets/XYZ/font.woff2", but instead we are given this kind of URL: https://XYZ.ddev.site/vendor/typo3/extension/Resources/Public/Css/fonts/TheMix/font.woff2.
Is their a way to call the font inside _assets directory?
All sites with a "mailto" can't load any more after activating the plugin. They are loading endless with a white site. No error will be generated in logs.
This same happens if a form is used on a site.
We have t3 v11.5.32 running with php 8.0 and min v. 2.1.3
Hello,
on a website that is larger and where an external crawler monitors the site, I analyzed the crawler logs last week and saw that a lot of merged-*-min.css.gz are collected there. During a test, I then saw that the minify files are created with every page view.
First load - 07.07.2024 - 11:47:57:
/typo3temp/assets/compressed/merged-1e691d4e2026e04f3027483bb0cd5cf8-min.css.gz?1720345677
Second load - 07.07.2024 - 11:48:38:
/typo3temp/assets/compressed/merged-1e691d4e2026e04f3027483bb0cd5cf8-min.css.gz?1720345718
In this commit, the check if the file has already been created was removed:
7fd9953#diff-0121e1183a0acdd190c5bbfdb63e3a197f72ee7e89c4c6407cd2a27589c0877dL129
Subject version: 3.0.1 (12 LTS) and 2.1.3 (11 LTS/10 LTS)
Solution idea:
Line 99 in 4966c4c
// File already created for this ext
if (file_exists($targetFilename)) {
$config['file'] = $targetFilename;
$filesAfterCompression[$targetFilename] = $config;
continue;
}
Bye
Björn
This happens if the default TS template is loaded.
/min/Configuration/TypoScript/setup.typoscript
Please change
[getTSFE() && getTSFE().isBackendUserLoggedIn() && request.getQueryParams()['debug'] > 0]
to
[getTSFE() && getTSFE().isBackendUserLoggedIn() && traverse(request.getQueryParams(), 'debug') > 0]
Thanks
Thanks armin for version 2 of this must have extension!
In the commit logs i saw a roadmap v2.1 task to provide optional CSS/JS compression for the "new" asset viewhelper. Is that still on your roadmap? That would be really cool, because the core still does not provide such a feature. https://forge.typo3.org/issues/91312
According to #11 (comment) the relative file paths in CSS files are not resolved correctly, when the new composer-installer v4 is involved.
PHP Warning: Undefined array key "priority" in /var/www/html/public/typo3conf/ext/min/Classes/EventListener/AssetRendererEventListener.php line 115
TYPO3 11.5.16
PHP 8.0.x
EXT:min 2.1.0
composer-mode
Hello, are there any plans for TYPO3 12 support?
I got several Log Entries:
"Core: Exception handler (CLI): Uncaught TYPO3 Exception: syntax error, unexpected '=' | ParseError thrown in file .../typo3temp/var/cache/code/core/ext_localconf_ccd1fa08068a0a0f1060a754943cb44d743d8f59.php in line 2028"
I could figured out, that the error point to line 18 in the EXT:min/ext_localconf.php.
I use php 7.4.28
TYPO3 11.5.27
PHP 8.1.18
min 2.1.2
composer installers v4
Since v2.1.2 the compression of assetcollector assets (css and js) does not work anymore. The assets are just ignored.
It seems that commit 2c92ec0 introduced a regression.
With v2.1.1
<link media="all" href="/typo3temp/assets/compressed/femanager-min.css.1685534495.gzip" rel="stylesheet">
<script src="/typo3temp/assets/compressed/Femanager.min-min.js.1685534495.gzip"></script>
With v2.1.2
<link media="all" href="/_assets/c1c23d805658c7c8c9054ca1396e79a3/Css/Extensions/femanager.1685107140.css" rel="stylesheet">
<script src="/_assets/f038457a108ded7ca0b077b63bfae195/JavaScript/Femanager.min.1682508541.js"></script>
Downgraded to v2.1.1 as temp workaround.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.