Encore added

This commit is contained in:
Joren de Graaf
2026-07-25 23:16:00 +02:00
parent 1401125706
commit 2c0432a4fe
14 changed files with 5033 additions and 2 deletions
+7
View File
@@ -8,3 +8,10 @@
/var/
/vendor/
###< symfony/framework-bundle ###
###> symfony/webpack-encore-bundle ###
/node_modules/
/public/build/
npm-debug.log
yarn-error.log
###< symfony/webpack-encore-bundle ###
+4
View File
@@ -0,0 +1,4 @@
import './styles/app.scss';
import htmx from 'htmx.org';
window.htmx = htmx;
+3
View File
@@ -0,0 +1,3 @@
body {
background-color: lightgray;
}
View File
+1
View File
@@ -17,6 +17,7 @@
"symfony/runtime": "8.1.*",
"symfony/security-bundle": "8.1.*",
"symfony/twig-bundle": "8.1.*",
"symfony/webpack-encore-bundle": "^2.4",
"symfony/yaml": "8.1.*"
},
"config": {
Generated
+147 -1
View File
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "c5abb52dd3e1e09021050455b61f2314",
"content-hash": "4727574c12cc62460fbd970446c9b9e1",
"packages": [
{
"name": "doctrine/collections",
@@ -1373,6 +1373,76 @@
},
"time": "2024-09-11T13:17:53+00:00"
},
{
"name": "symfony/asset",
"version": "v8.1.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/asset.git",
"reference": "4bd4d143b7e53f40d45877df52eb2b18282bdac4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/asset/zipball/4bd4d143b7e53f40d45877df52eb2b18282bdac4",
"reference": "4bd4d143b7e53f40d45877df52eb2b18282bdac4",
"shasum": ""
},
"require": {
"php": ">=8.4.1"
},
"require-dev": {
"symfony/http-client": "^7.4|^8.0",
"symfony/http-foundation": "^7.4|^8.0",
"symfony/http-kernel": "^7.4|^8.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Symfony\\Component\\Asset\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Manages URL generation and versioning of web assets such as CSS stylesheets, JavaScript files and image files",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/asset/tree/v8.1.0"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://github.com/nicolas-grekas",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2026-05-29T05:06:50+00:00"
},
{
"name": "symfony/cache",
"version": "v8.1.1",
@@ -4865,6 +4935,82 @@
],
"time": "2026-06-27T09:05:56+00:00"
},
{
"name": "symfony/webpack-encore-bundle",
"version": "v2.4.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/webpack-encore-bundle.git",
"reference": "cac8d6c722999c8add9272f9de6e8079628df4f5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/webpack-encore-bundle/zipball/cac8d6c722999c8add9272f9de6e8079628df4f5",
"reference": "cac8d6c722999c8add9272f9de6e8079628df4f5",
"shasum": ""
},
"require": {
"php": ">=8.1.0",
"symfony/asset": "^5.4 || ^6.2 || ^7.0 || ^8.0",
"symfony/config": "^5.4 || ^6.2 || ^7.0 || ^8.0",
"symfony/dependency-injection": "^5.4 || ^6.2 || ^7.0 || ^8.0",
"symfony/http-kernel": "^5.4 || ^6.2 || ^7.0 || ^8.0",
"symfony/service-contracts": "^1.1.9 || ^2.1.3 || ^3.0"
},
"require-dev": {
"symfony/framework-bundle": "^5.4 || ^6.2 || ^7.0 || ^8.0",
"symfony/http-client": "^5.4 || ^6.2 || ^7.0 || ^8.0",
"symfony/phpunit-bridge": "^5.4 || ^6.2 || ^7.0 || ^8.0",
"symfony/twig-bundle": "^5.4 || ^6.2 || ^7.0 || ^8.0",
"symfony/web-link": "^5.4 || ^6.2 || ^7.0 || ^8.0"
},
"type": "symfony-bundle",
"extra": {
"thanks": {
"url": "https://github.com/symfony/webpack-encore",
"name": "symfony/webpack-encore"
}
},
"autoload": {
"psr-4": {
"Symfony\\WebpackEncoreBundle\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Integration of your Symfony app with Webpack Encore",
"support": {
"issues": "https://github.com/symfony/webpack-encore-bundle/issues",
"source": "https://github.com/symfony/webpack-encore-bundle/tree/v2.4.1"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://github.com/nicolas-grekas",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2026-06-24T07:21:58+00:00"
},
{
"name": "symfony/yaml",
"version": "v8.1.1",
+1
View File
@@ -8,4 +8,5 @@ return [
Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true],
Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],
Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true],
];
+45
View File
@@ -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
+15 -1
View File
@@ -267,7 +267,7 @@ use Symfony\Component\Config\Loader\ParamConfigurator as Param;
* formats?: array<string, string|list<scalar|Param|null>>,
* },
* assets?: bool|array{ // Assets configuration
* enabled?: bool|Param, // Default: false
* enabled?: bool|Param, // Default: true
* strict_mode?: bool|Param, // Throw an exception if an entry is missing from the manifest.json. // Default: false
* version_strategy?: scalar|Param|null, // Default: null
* version?: scalar|Param|null, // Default: null
@@ -1263,6 +1263,16 @@ use Symfony\Component\Config\Loader\ParamConfigurator as Param;
* intercept_redirects?: bool|Param, // Default: false
* excluded_ajax_paths?: scalar|Param|null, // Default: "^/((index|app(_[\\w]+)?)\\.php/)?_wdt"
* }
* @psalm-type WebpackEncoreConfig = array{
* output_path?: scalar|Param|null, // The path where Encore is building the assets - i.e. Encore.setOutputPath()
* crossorigin?: false|"anonymous"|"use-credentials"|Param, // crossorigin value when Encore.enableIntegrityHashes() is used, can be false (default), anonymous or use-credentials // Default: false
* preload?: bool|Param, // preload all rendered script and link tags automatically via the http2 Link header. // Default: false
* cache?: bool|Param, // Enable caching of the entry point file(s) // Default: false
* strict_mode?: bool|Param, // Throw an exception if the entrypoints.json file is missing or an entry is missing from the data // Default: true
* builds?: array<string, scalar|Param|null>,
* script_attributes?: array<string, scalar|Param|null>,
* link_attributes?: array<string, scalar|Param|null>,
* }
* @psalm-type ConfigType = array{
* imports?: ImportsConfig,
* parameters?: ParametersConfig,
@@ -1272,6 +1282,7 @@ use Symfony\Component\Config\Loader\ParamConfigurator as Param;
* doctrine_migrations?: DoctrineMigrationsConfig,
* security?: SecurityConfig,
* twig?: TwigConfig,
* webpack_encore?: WebpackEncoreConfig,
* "when@dev"?: array{
* imports?: ImportsConfig,
* parameters?: ParametersConfig,
@@ -1283,6 +1294,7 @@ use Symfony\Component\Config\Loader\ParamConfigurator as Param;
* security?: SecurityConfig,
* twig?: TwigConfig,
* web_profiler?: WebProfilerConfig,
* webpack_encore?: WebpackEncoreConfig,
* },
* "when@prod"?: array{
* imports?: ImportsConfig,
@@ -1293,6 +1305,7 @@ use Symfony\Component\Config\Loader\ParamConfigurator as Param;
* doctrine_migrations?: DoctrineMigrationsConfig,
* security?: SecurityConfig,
* twig?: TwigConfig,
* webpack_encore?: WebpackEncoreConfig,
* },
* "when@test"?: array{
* imports?: ImportsConfig,
@@ -1304,6 +1317,7 @@ use Symfony\Component\Config\Loader\ParamConfigurator as Param;
* security?: SecurityConfig,
* twig?: TwigConfig,
* web_profiler?: WebProfilerConfig,
* webpack_encore?: WebpackEncoreConfig,
* },
* ...<string, ExtensionType|array{ // extra keys must follow the when@%env% pattern or match an extension alias
* imports?: ImportsConfig,
+4698
View File
File diff suppressed because it is too large Load Diff
+16
View File
@@ -0,0 +1,16 @@
{
"scripts": {
"dev-server": "encore dev-server",
"dev": "encore dev",
"watch": "encore dev --watch",
"build": "encore production --progress"
},
"dependencies": {
"htmx.org": "^2.0.10"
},
"devDependencies": {
"@symfony/webpack-encore": "^7.1.0",
"sass": "^1.102.0",
"sass-loader": "^17.0.0"
}
}
+16
View File
@@ -152,5 +152,21 @@
"config/packages/web_profiler.yaml",
"config/routes/web_profiler.yaml"
]
},
"symfony/webpack-encore-bundle": {
"version": "2.4",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "2.2",
"ref": "b618bf5f17ed61f523da7153025bf58ec9502f65"
},
"files": [
"assets/app.js",
"assets/styles/app.css",
"config/packages/webpack_encore.yaml",
"package.json",
"webpack.config.js"
]
}
}
+2
View File
@@ -5,9 +5,11 @@
<title>{% block title %}Welcome!{% endblock %}</title>
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 128 128%22><text y=%221.2em%22 font-size=%2296%22>⚫️</text><text y=%221.3em%22 x=%220.2em%22 font-size=%2276%22 fill=%22%23fff%22>sf</text></svg>">
{% block stylesheets %}
{{ encore_entry_link_tags('app') }}
{% endblock %}
{% block javascripts %}
{{ encore_entry_script_tags('app') }}
{% endblock %}
{% set frankenphp_hot_reload = app.request.server.get('FRANKENPHP_HOT_RELOAD') %}
+78
View File
@@ -0,0 +1,78 @@
import Encore from '@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()
// Displays build status system notifications to the user
// .enableBuildNotifications()
.enableSourceMaps(!Encore.isProduction())
// enables hashed filenames (e.g. app.abc123.css)
.enableVersioning(Encore.isProduction())
// Configure JS and CSS minimizers
// .configureJsMinimizerPlugin((options, MinimizerPlugin) => {
// options.minify = MinimizerPlugin.esbuildMinify
// })
// .configureCssMinimizerPlugin((options, MinimizerPlugin) => {
// options.minify = MinimizerPlugin.lightningCssMinify;
// })
// configure Babel
.configureBabel((config) => {
config.plugins.push(['polyfill-corejs3', { method: 'usage-global', version: '3.49' }]);
})
// 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()
;
export default await Encore.getWebpackConfig();