-
-
Notifications
You must be signed in to change notification settings - Fork 482
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
[AssetMapper] surrounding importmap() in a block #1268
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This allows it to be overridden (independent of javascripts block) so we can completely override it (no parent)
Thanks for the PR 😍 How to test these changes in your application
Diff between recipe versionsIn order to help with the review stage, I'm in charge of computing the diff between the various versions of patched recipes. symfony/asset-mapper6.3 vs 6.4diff --git a/symfony/asset-mapper/6.3/assets/app.js b/symfony/asset-mapper/6.4/assets/app.js
index cb0082a..e3b03ad 100644
--- a/symfony/asset-mapper/6.3/assets/app.js
+++ b/symfony/asset-mapper/6.4/assets/app.js
@@ -4,4 +4,6 @@
* This file will be included onto the page via the importmap() Twig function,
* which should already be in your base.html.twig.
*/
+import './styles/app.css'
+
console.log('This log comes from assets/app.js - welcome to AssetMapper! 🎉')
diff --git a/symfony/asset-mapper/6.3/importmap.php b/symfony/asset-mapper/6.4/importmap.php
index 5c2c21d..9be0d4c 100644
--- a/symfony/asset-mapper/6.3/importmap.php
+++ b/symfony/asset-mapper/6.4/importmap.php
@@ -6,8 +6,8 @@
* - "path" is a path inside the asset mapper system. Use the
* "debug:asset-map" command to see the full list of paths.
*
- * - "preload" set to true for any modules that are loaded on the initial
- * page load to help the browser download them earlier.
+ * - "entrypoint" (JavaScript only) set to true for any module that will
+ * be used as an "entrypoint" (and passed to the importmap() Twig function).
*
* The "importmap:require" command can be used to add new entries to this file.
*
@@ -15,7 +15,7 @@
*/
return [
'app' => [
- 'path' => 'app.js',
- 'preload' => true,
+ 'path' => './assets/app.js',
+ 'entrypoint' => true,
],
];
diff --git a/symfony/asset-mapper/6.3/manifest.json b/symfony/asset-mapper/6.4/manifest.json
index c6fb477..8943ae7 100644
--- a/symfony/asset-mapper/6.3/manifest.json
+++ b/symfony/asset-mapper/6.4/manifest.json
@@ -6,22 +6,16 @@
},
"aliases": ["asset-mapper", "importmap"],
"gitignore": [
- "/%PUBLIC_DIR%/assets/"
+ "/%PUBLIC_DIR%/assets/",
+ "/assets/vendor"
],
"add-lines": [
{
"file": "templates/base.html.twig",
- "content": " {{ importmap() }}",
+ "content": "{% block importmap %}{{ importmap('app') }}{% endblock %}",
"position": "after_target",
"target": "{% block javascripts %}",
"warn_if_missing": true
- },
- {
- "file": "templates/base.html.twig",
- "content": " <link rel=\"stylesheet\" href=\"{{ asset('styles/app.css') }}\">",
- "position": "after_target",
- "target": "{% block stylesheets %}",
- "warn_if_missing": true
}
],
"conflict": { |
fabpot
approved these changes
Dec 10, 2023
javiereguiluz
added a commit
to symfony/symfony-docs
that referenced
this pull request
Dec 13, 2023
…yan) This PR was merged into the 6.4 branch. Discussion ---------- [AssetMapper] Adding note about importmap block Docs for symfony/recipes#1268 Commits ------- e273ed1 [AssetMapper] Adding note about importmap block
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If you want to have page-specific JS, you need to override
{{ importmap() }}
and NOT call it twice. If you overridejavascripts
and do not callparent()
, it could accidentally not include some other JS you have. So, the proposal is to wrap{{ importmap() }}
in its own block so you can override it.