diff --git a/README.rst b/README.rst index ab9249e8..8959e926 100644 --- a/README.rst +++ b/README.rst @@ -313,6 +313,44 @@ colors`_ are supported too: * Read the documentation at https://symfony.com/doc +``add-lines`` Configurator +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +If no other configurators can meet your needs, the ``add-lines`` configurator +can add entire lines to files, either at the top, bottom or after a target: + +.. code-block:: json + + "add-lines": [ + { + "file": "webpack.config.js", + "content": "\nenables the Symfony UX Stimulus bridge (used in assets/bootstrap.js)\n .enableStimulusBridge('./assets/controllers.json')", + "position": "after_target", + "target": ".splitEntryChunks()" + }, + { + "file": "assets/app.js", + "content": "import './bootstrap.js';", + "position": "top", + "warn_if_missing": true + }, + { + "file": "assets/translator.js", + "content": "export * from '../var/translations';", + "position": "bottom", + "requires": "symfony/webpack-encore-bundle" + } + ] + +Each item needs ``file``, ``content`` and ``position``, which can be +``top``, ``bottom`` or ``after_target``. If ``after_target`` is used, a +``target`` must also be specified, which is a string that will be searched for +in the file. + +If ``warn_if_missing`` is set to ``true``, a warning will be shown to the +user if the ``file`` or ``target`` isn't found. If ``requires`` is set, the +rule will only be applied if the given package is installed. + Validation ---------- diff --git a/symfony/asset-mapper/6.3/assets/app.js b/symfony/asset-mapper/6.3/assets/app.js new file mode 100644 index 00000000..cb0082a8 --- /dev/null +++ b/symfony/asset-mapper/6.3/assets/app.js @@ -0,0 +1,7 @@ +/* + * Welcome to your app's main JavaScript file! + * + * This file will be included onto the page via the importmap() Twig function, + * which should already be in your base.html.twig. + */ +console.log('This log comes from assets/app.js - welcome to AssetMapper! 🎉') diff --git a/symfony/asset-mapper/6.3/assets/styles/app.css b/symfony/asset-mapper/6.3/assets/styles/app.css new file mode 100644 index 00000000..dd6181a1 --- /dev/null +++ b/symfony/asset-mapper/6.3/assets/styles/app.css @@ -0,0 +1,3 @@ +body { + background-color: skyblue; +} diff --git a/symfony/asset-mapper/6.3/config/packages/asset_mapper.yaml b/symfony/asset-mapper/6.3/config/packages/asset_mapper.yaml new file mode 100644 index 00000000..d1ac653b --- /dev/null +++ b/symfony/asset-mapper/6.3/config/packages/asset_mapper.yaml @@ -0,0 +1,5 @@ +framework: + asset_mapper: + # The paths to make available to the asset mapper. + paths: + - assets/ diff --git a/symfony/asset-mapper/6.3/importmap.php b/symfony/asset-mapper/6.3/importmap.php new file mode 100644 index 00000000..5c2c21d8 --- /dev/null +++ b/symfony/asset-mapper/6.3/importmap.php @@ -0,0 +1,21 @@ + [ + 'path' => 'app.js', + 'preload' => true, + ], +]; diff --git a/symfony/asset-mapper/6.3/manifest.json b/symfony/asset-mapper/6.3/manifest.json new file mode 100644 index 00000000..c6fb477e --- /dev/null +++ b/symfony/asset-mapper/6.3/manifest.json @@ -0,0 +1,32 @@ +{ + "copy-from-recipe": { + "assets/": "assets/", + "config/": "%CONFIG_DIR%/", + "importmap.php": "importmap.php" + }, + "aliases": ["asset-mapper", "importmap"], + "gitignore": [ + "/%PUBLIC_DIR%/assets/" + ], + "add-lines": [ + { + "file": "templates/base.html.twig", + "content": " {{ importmap() }}", + "position": "after_target", + "target": "{% block javascripts %}", + "warn_if_missing": true + }, + { + "file": "templates/base.html.twig", + "content": " ", + "position": "after_target", + "target": "{% block stylesheets %}", + "warn_if_missing": true + } + ], + "conflict": { + "symfony/framework-bundle": "<6.3", + "symfony/twig-bundle": "<6.3", + "symfony/flex": "<1.20.0 || >=2.0.0,<2.3.0" + } +} diff --git a/symfony/stimulus-bundle/2.9/assets/bootstrap.js b/symfony/stimulus-bundle/2.9/assets/bootstrap.js new file mode 100644 index 00000000..2689398a --- /dev/null +++ b/symfony/stimulus-bundle/2.9/assets/bootstrap.js @@ -0,0 +1,2 @@ +// register any custom, 3rd party controllers here +// app.register('some_controller_name', SomeImportedController); diff --git a/symfony/stimulus-bundle/2.9/assets/controllers.json b/symfony/stimulus-bundle/2.9/assets/controllers.json new file mode 100644 index 00000000..a1c6e90c --- /dev/null +++ b/symfony/stimulus-bundle/2.9/assets/controllers.json @@ -0,0 +1,4 @@ +{ + "controllers": [], + "entrypoints": [] +} diff --git a/symfony/stimulus-bundle/2.9/assets/controllers/hello_controller.js b/symfony/stimulus-bundle/2.9/assets/controllers/hello_controller.js new file mode 100644 index 00000000..e847027b --- /dev/null +++ b/symfony/stimulus-bundle/2.9/assets/controllers/hello_controller.js @@ -0,0 +1,16 @@ +import { Controller } from '@hotwired/stimulus'; + +/* + * This is an example Stimulus controller! + * + * Any element with a data-controller="hello" attribute will cause + * this controller to be executed. The name "hello" comes from the filename: + * hello_controller.js -> "hello" + * + * Delete this file or adapt it for your use! + */ +export default class extends Controller { + connect() { + this.element.textContent = 'Hello Stimulus! Edit me in assets/controllers/hello_controller.js'; + } +} diff --git a/symfony/stimulus-bundle/2.9/manifest.json b/symfony/stimulus-bundle/2.9/manifest.json new file mode 100644 index 00000000..f9f14452 --- /dev/null +++ b/symfony/stimulus-bundle/2.9/manifest.json @@ -0,0 +1,46 @@ +{ + "bundles": { + "Symfony\\UX\\StimulusBundle\\StimulusBundle": ["all"] + }, + "copy-from-recipe": { + "assets/": "assets/" + }, + "aliases": ["stimulus", "stimulus-bundle"], + "conflict": { + "symfony/webpack-encore-bundle": "<2.0", + "symfony/flex": "<1.20.0 || >=2.0.0,<2.3.0" + }, + "add-lines": [ + { + "file": "webpack.config.js", + "content": "\n // enables the Symfony UX Stimulus bridge (used in assets/bootstrap.js)\n .enableStimulusBridge('./assets/controllers.json')", + "position": "after_target", + "target": ".splitEntryChunks()" + }, + { + "file": "assets/app.js", + "content": "import './bootstrap.js';", + "position": "top", + "warn_if_missing": true + }, + { + "file": "assets/bootstrap.js", + "content": "import { startStimulusApp } from '@symfony/stimulus-bridge';\n\n// Registers Stimulus controllers from controllers.json and in the controllers/ directory\nexport const app = startStimulusApp(require.context(\n '@symfony/stimulus-bridge/lazy-controller-loader!./controllers',\n true,\n /\\.[jt]sx?$/\n));", + "position": "top", + "requires": "symfony/webpack-encore-bundle" + }, + { + "file": "assets/bootstrap.js", + "content": "import { startStimulusApp } from '@symfony/stimulus-bundle';\n\nconst app = startStimulusApp();", + "position": "top", + "requires": "symfony/asset-mapper" + }, + { + "file": "templates/base.html.twig", + "content": " {{ ux_controller_link_tags() }}", + "position": "after_target", + "target": "{% block stylesheets %}", + "warn_if_missing": true + } + ] +} diff --git a/symfony/twig-bundle/6.3/config/packages/twig.yaml b/symfony/twig-bundle/6.3/config/packages/twig.yaml new file mode 100644 index 00000000..f9f4cc53 --- /dev/null +++ b/symfony/twig-bundle/6.3/config/packages/twig.yaml @@ -0,0 +1,6 @@ +twig: + default_path: '%kernel.project_dir%/templates' + +when@test: + twig: + strict_variables: true diff --git a/symfony/twig-bundle/6.3/manifest.json b/symfony/twig-bundle/6.3/manifest.json new file mode 100644 index 00000000..c4835ac7 --- /dev/null +++ b/symfony/twig-bundle/6.3/manifest.json @@ -0,0 +1,12 @@ +{ + "bundles": { + "Symfony\\Bundle\\TwigBundle\\TwigBundle": ["all"] + }, + "copy-from-recipe": { + "config/": "%CONFIG_DIR%/", + "templates/": "templates/" + }, + "conflict": { + "symfony/framework-bundle": "<5.3" + } +} diff --git a/symfony/twig-bundle/6.3/templates/base.html.twig b/symfony/twig-bundle/6.3/templates/base.html.twig new file mode 100644 index 00000000..67598ac2 --- /dev/null +++ b/symfony/twig-bundle/6.3/templates/base.html.twig @@ -0,0 +1,16 @@ + + + + + {% block title %}Welcome!{% endblock %} + + {% block stylesheets %} + {% endblock %} + + {% block javascripts %} + {% endblock %} + + + {% block body %}{% endblock %} + + diff --git a/symfony/ux-translator/2.7/assets/translator.js b/symfony/ux-translator/2.8/assets/translator.js similarity index 100% rename from symfony/ux-translator/2.7/assets/translator.js rename to symfony/ux-translator/2.8/assets/translator.js diff --git a/symfony/ux-translator/2.7/config/packages/ux_translator.yaml b/symfony/ux-translator/2.8/config/packages/ux_translator.yaml similarity index 100% rename from symfony/ux-translator/2.7/config/packages/ux_translator.yaml rename to symfony/ux-translator/2.8/config/packages/ux_translator.yaml diff --git a/symfony/ux-translator/2.7/manifest.json b/symfony/ux-translator/2.8/manifest.json similarity index 100% rename from symfony/ux-translator/2.7/manifest.json rename to symfony/ux-translator/2.8/manifest.json diff --git a/symfony/ux-translator/2.9/assets/translator.js b/symfony/ux-translator/2.9/assets/translator.js new file mode 100644 index 00000000..28012a65 --- /dev/null +++ b/symfony/ux-translator/2.9/assets/translator.js @@ -0,0 +1,13 @@ +import { trans, getLocale, setLocale, setLocaleFallbacks } from '@symfony/ux-translator'; +/* + * This file is part of the Symfony UX Translator package. + * + * If folder "../var/translations" does not exist, or some translations are missing, + * you must warmup your Symfony cache to refresh JavaScript translations. + * + * If you use TypeScript, you can rename this file to "translator.ts" to take advantage of types checking. + */ + +setLocaleFallbacks(localeFallbacks); + +export { trans }; diff --git a/symfony/ux-translator/2.9/config/packages/ux_translator.yaml b/symfony/ux-translator/2.9/config/packages/ux_translator.yaml new file mode 100644 index 00000000..1c1c7060 --- /dev/null +++ b/symfony/ux-translator/2.9/config/packages/ux_translator.yaml @@ -0,0 +1,3 @@ +ux_translator: + # The directory where the JavaScript translations are dumped + dump_directory: '%kernel.project_dir%/var/translations' diff --git a/symfony/ux-translator/2.9/manifest.json b/symfony/ux-translator/2.9/manifest.json new file mode 100644 index 00000000..a1ac08ba --- /dev/null +++ b/symfony/ux-translator/2.9/manifest.json @@ -0,0 +1,39 @@ +{ + "bundles": { + "Symfony\\UX\\Translator\\UxTranslatorBundle": ["all"] + }, + "conflict": { + "symfony/flex": "<1.20.0 || >=2.0.0,<2.3.0" + }, + "copy-from-recipe": { + "assets/": "assets/", + "config/": "%CONFIG_DIR%/", + "var/": "var/" + }, + "add-lines": [ + { + "file": "assets/translator.js", + "content": "import { localeFallbacks } from '../var/translations/configuration';", + "position": "top", + "requires": "symfony/webpack-encore-bundle" + }, + { + "file": "assets/translator.js", + "content": "import { localeFallbacks } from '@app/translations/configuration';", + "position": "top", + "requires": "symfony/asset-mapper" + }, + { + "file": "assets/translator.js", + "content": "export * from '../var/translations';", + "position": "bottom", + "requires": "symfony/webpack-encore-bundle" + }, + { + "file": "assets/translator.js", + "content": "export * from '@app/translations';", + "position": "bottom", + "requires": "symfony/asset-mapper" + } + ] +} diff --git a/symfony/ux-translator/2.9/var/translations/configuration.js b/symfony/ux-translator/2.9/var/translations/configuration.js new file mode 100644 index 00000000..bea96d63 --- /dev/null +++ b/symfony/ux-translator/2.9/var/translations/configuration.js @@ -0,0 +1,3 @@ +export const localeFallbacks = {}; + +console.log('Run bin/console cache:warmup to generate the translation files.'); diff --git a/symfony/ux-translator/2.9/var/translations/index.js b/symfony/ux-translator/2.9/var/translations/index.js new file mode 100644 index 00000000..34f7c1ba --- /dev/null +++ b/symfony/ux-translator/2.9/var/translations/index.js @@ -0,0 +1 @@ +console.log('Run bin/console cache:warmup to generate the translation files.'); diff --git a/symfony/webpack-encore-bundle/1.10/manifest.json b/symfony/webpack-encore-bundle/1.10/manifest.json index a2728ca2..39b0363e 100644 --- a/symfony/webpack-encore-bundle/1.10/manifest.json +++ b/symfony/webpack-encore-bundle/1.10/manifest.json @@ -8,7 +8,7 @@ "package.json": "package.json", "webpack.config.js": "webpack.config.js" }, - "aliases": ["ux", "encore", "webpack", "webpack-encore"], + "aliases": ["encore", "webpack", "webpack-encore"], "gitignore": [ "/node_modules/", "/%PUBLIC_DIR%/build/", diff --git a/symfony/webpack-encore-bundle/2.0/assets/app.js b/symfony/webpack-encore-bundle/2.0/assets/app.js new file mode 100644 index 00000000..85065048 --- /dev/null +++ b/symfony/webpack-encore-bundle/2.0/assets/app.js @@ -0,0 +1,9 @@ +/* + * Welcome to your app's main JavaScript file! + * + * We recommend including the built version of this JavaScript file + * (and its CSS file) in your base layout (base.html.twig). + */ + +// any CSS you import will output into a single css file (app.css in this case) +import './styles/app.css'; diff --git a/symfony/webpack-encore-bundle/2.0/assets/styles/app.css b/symfony/webpack-encore-bundle/2.0/assets/styles/app.css new file mode 100644 index 00000000..cb33b131 --- /dev/null +++ b/symfony/webpack-encore-bundle/2.0/assets/styles/app.css @@ -0,0 +1,3 @@ +body { + background-color: lightgray; +} diff --git a/symfony/webpack-encore-bundle/2.0/config/packages/webpack_encore.yaml b/symfony/webpack-encore-bundle/2.0/config/packages/webpack_encore.yaml new file mode 100644 index 00000000..4c009ee4 --- /dev/null +++ b/symfony/webpack-encore-bundle/2.0/config/packages/webpack_encore.yaml @@ -0,0 +1,45 @@ +webpack_encore: + # The path where Encore is building the assets - i.e. Encore.setOutputPath() + output_path: '%kernel.project_dir%/public/build' + # If multiple builds are defined (as shown below), you can disable the default build: + # output_path: false + + # Set attributes that will be rendered on all script and link tags + script_attributes: + defer: true + # Uncomment (also under link_attributes) if using Turbo Drive + # https://turbo.hotwired.dev/handbook/drive#reloading-when-assets-change + # 'data-turbo-track': reload + # link_attributes: + # Uncomment if using Turbo Drive + # 'data-turbo-track': reload + + # If using Encore.enableIntegrityHashes() and need the crossorigin attribute (default: false, or use 'anonymous' or 'use-credentials') + # crossorigin: 'anonymous' + + # Preload all rendered script and link tags automatically via the HTTP/2 Link header + # preload: true + + # Throw an exception if the entrypoints.json file is missing or an entry is missing from the data + # strict_mode: false + + # If you have multiple builds: + # builds: + # frontend: '%kernel.project_dir%/public/frontend/build' + + # pass the build name as the 3rd argument to the Twig functions + # {{ encore_entry_script_tags('entry1', null, 'frontend') }} + +framework: + assets: + json_manifest_path: '%kernel.project_dir%/public/build/manifest.json' + +#when@prod: +# webpack_encore: +# # Cache the entrypoints.json (rebuild Symfony's cache when entrypoints.json changes) +# # Available in version 1.2 +# cache: true + +#when@test: +# webpack_encore: +# strict_mode: false diff --git a/symfony/webpack-encore-bundle/2.0/manifest.json b/symfony/webpack-encore-bundle/2.0/manifest.json new file mode 100644 index 00000000..6c2c5429 --- /dev/null +++ b/symfony/webpack-encore-bundle/2.0/manifest.json @@ -0,0 +1,38 @@ +{ + "bundles": { + "Symfony\\WebpackEncoreBundle\\WebpackEncoreBundle": ["all"] + }, + "copy-from-recipe": { + "assets/": "assets/", + "config/": "%CONFIG_DIR%/", + "package.json": "package.json", + "webpack.config.js": "webpack.config.js" + }, + "aliases": ["ux", "encore", "webpack", "webpack-encore"], + "gitignore": [ + "/node_modules/", + "/%PUBLIC_DIR%/build/", + "npm-debug.log", + "yarn-error.log" + ], + "conflict": { + "symfony/framework-bundle": "<5.4", + "symfony/flex": "<1.20.0 || >=2.0.0,<2.3.0" + }, + "add-lines": [ + { + "file": "templates/base.html.twig", + "content": " {{ encore_entry_script_tags('app') }}", + "position": "after_target", + "target": "{% block javascripts %}", + "warn_if_missing": true + }, + { + "file": "templates/base.html.twig", + "content": " {{ encore_entry_link_tags('app') }}", + "position": "after_target", + "target": "{% block stylesheets %}", + "warn_if_missing": true + } + ] +} diff --git a/symfony/webpack-encore-bundle/2.0/package.json b/symfony/webpack-encore-bundle/2.0/package.json new file mode 100644 index 00000000..b4ce2a66 --- /dev/null +++ b/symfony/webpack-encore-bundle/2.0/package.json @@ -0,0 +1,20 @@ +{ + "devDependencies": { + "@babel/core": "^7.17.0", + "@babel/preset-env": "^7.16.0", + "@symfony/webpack-encore": "^4.0.0", + "core-js": "^3.23.0", + "regenerator-runtime": "^0.13.9", + "webpack": "^5.74.0", + "webpack-cli": "^4.10.0", + "webpack-notifier": "^1.15.0" + }, + "license": "UNLICENSED", + "private": true, + "scripts": { + "dev-server": "encore dev-server", + "dev": "encore dev", + "watch": "encore dev --watch", + "build": "encore production --progress" + } +} diff --git a/symfony/webpack-encore-bundle/2.0/post-install.txt b/symfony/webpack-encore-bundle/2.0/post-install.txt new file mode 100644 index 00000000..e53f05dc --- /dev/null +++ b/symfony/webpack-encore-bundle/2.0/post-install.txt @@ -0,0 +1,3 @@ + * Install Yarn and run yarn install + + * Start the development server: yarn encore dev-server diff --git a/symfony/webpack-encore-bundle/2.0/webpack.config.js b/symfony/webpack-encore-bundle/2.0/webpack.config.js new file mode 100644 index 00000000..9d752df4 --- /dev/null +++ b/symfony/webpack-encore-bundle/2.0/webpack.config.js @@ -0,0 +1,73 @@ +const Encore = require('@symfony/webpack-encore'); + +// Manually configure the runtime environment if not already configured yet by the "encore" command. +// It's useful when you use tools that rely on webpack.config.js file. +if (!Encore.isRuntimeEnvironmentConfigured()) { + Encore.configureRuntimeEnvironment(process.env.NODE_ENV || 'dev'); +} + +Encore + // directory where compiled assets will be stored + .setOutputPath('public/build/') + // public path used by the web server to access the output path + .setPublicPath('/build') + // only needed for CDN's or subdirectory deploy + //.setManifestKeyPrefix('build/') + + /* + * ENTRY CONFIG + * + * Each entry will result in one JavaScript file (e.g. app.js) + * and one CSS file (e.g. app.css) if your JavaScript imports CSS. + */ + .addEntry('app', './assets/app.js') + + // When enabled, Webpack "splits" your files into smaller pieces for greater optimization. + .splitEntryChunks() + + // will require an extra script tag for runtime.js + // but, you probably want this, unless you're building a single-page app + .enableSingleRuntimeChunk() + + /* + * FEATURE CONFIG + * + * Enable & configure other features below. For a full + * list of features, see: + * https://symfony.com/doc/current/frontend.html#adding-more-features + */ + .cleanupOutputBeforeBuild() + .enableBuildNotifications() + .enableSourceMaps(!Encore.isProduction()) + // enables hashed filenames (e.g. app.abc123.css) + .enableVersioning(Encore.isProduction()) + + // configure Babel + // .configureBabel((config) => { + // config.plugins.push('@babel/a-babel-plugin'); + // }) + + // enables and configure @babel/preset-env polyfills + .configureBabelPresetEnv((config) => { + config.useBuiltIns = 'usage'; + config.corejs = '3.23'; + }) + + // enables Sass/SCSS support + //.enableSassLoader() + + // uncomment if you use TypeScript + //.enableTypeScriptLoader() + + // uncomment if you use React + //.enableReactPreset() + + // uncomment to get integrity="..." attributes on your script & link tags + // requires WebpackEncoreBundle 1.4 or higher + //.enableIntegrityHashes(Encore.isProduction()) + + // uncomment if you're having problems with a jQuery plugin + //.autoProvidejQuery() +; + +module.exports = Encore.getWebpackConfig();