Skip to content

Commit

Permalink
✨ Replace WebpackEncore with AssetMapper
Browse files Browse the repository at this point in the history
  • Loading branch information
ker0x committed Aug 25, 2024
1 parent 6349f93 commit f885b51
Show file tree
Hide file tree
Showing 33 changed files with 662 additions and 5,987 deletions.
10 changes: 3 additions & 7 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,9 @@ APP_SECRET=c7fb94ce5b34733d6c7fbadcadab8ee7
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
#
# DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
# DATABASE_URL="mysql://app:[email protected]:3306/app?serverVersion=8&charset=utf8mb4"
POSTGRES_DB=app
POSTGRES_VERSION=16
POSTGRES_USER=app
POSTGRES_PASSWORD=!ChangeMe!

DATABASE_URL="postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@database:5432/$POSTGRES_DB?serverVersion=$POSTGRES_VERSION&charset=utf8"
# DATABASE_URL="mysql://app:[email protected]:3306/app?serverVersion=8.0.32&charset=utf8mb4"
# DATABASE_URL="mysql://app:[email protected]:3306/app?serverVersion=10.11.2-MariaDB&charset=utf8mb4"
DATABASE_URL="postgresql://app:[email protected]:5432/app?serverVersion=16&charset=utf8"
###< doctrine/doctrine-bundle ###

###> symfony/free-mobile-notifier ###
Expand Down
23 changes: 10 additions & 13 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

###> symfony/framework-bundle ###
/.env.local
/.env.local.php
Expand All @@ -14,23 +13,21 @@
/.php-cs-fixer.cache
###< friendsofphp/php-cs-fixer ###

###> symfony/phpunit-bridge ###
/.phpunit.result.cache
/.phpunit.cache/
/phpunit.xml
###< symfony/phpunit-bridge ###

###> symfony/webpack-encore-bundle ###
/node_modules/
/public/build/
npm-debug.log
yarn-error.log
###< symfony/webpack-encore-bundle ###
###> symfony/asset-mapper ###
/public/assets/
/assets/vendor/
###< symfony/asset-mapper ###

###> phpstan/phpstan ###
phpstan.neon
###< phpstan/phpstan ###

###> phpunit/phpunit ###
/.phpunit.cache/
/coverage/
/phpunit.xml
###< phpunit/phpunit ###

###> vincentlanglet/twig-cs-fixer ###
/.twig-cs-fixer.cache
###< vincentlanglet/twig-cs-fixer ###
24 changes: 20 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,15 @@ composer: ## Run composer, pass the parameter "c=" to run a given command, examp
@$(COMPOSER) $(c)
.PHONY: composer

vendor: ## Install vendors according to the current composer.lock file
vendor: c=install --prefer-dist --no-dev --no-progress --no-scripts --no-interaction
vendor: composer
.PHONY: vendor
install: ## Install vendors according to the current composer.lock file
install: c=install --prefer-dist --no-dev --no-progress --no-scripts --no-interaction
install: composer
.PHONY: install

update: ## Update vendors
update: c=update
update: composer
.PHONY: update

##
## —— Symfony 🎵 ———————————————————————————————————————————————————————————————
Expand Down Expand Up @@ -108,6 +113,17 @@ router: c=debug:router ## Display all available route
router: sf
.PHONY: router

asset-map: c=debug:asset-map ## Display all mapped assets
asset-map: sf
.PHONY: asset-map

##
## —— Assets 🎨 ————————————————————————————————————————————————————————————————
##
tailwind: c=tailwind:build --watch --poll ## Build CSS
tailwind: sf
.PHONY: tailwind

##
## —— Database 🔮 ——————————————————————————————————————————————————————————————
##
Expand Down
9 changes: 9 additions & 0 deletions assets/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* 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.
*/
import './styles/app.css';

import './bootstrap.js';
6 changes: 6 additions & 0 deletions assets/bootstrap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { startStimulusApp } from '@symfony/stimulus-bundle';

const app = startStimulusApp();

// register any custom, 3rd party controllers here
// app.register('some_controller_name', SomeImportedController);
24 changes: 24 additions & 0 deletions assets/controllers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"controllers": {
"@symfony/ux-live-component": {
"live": {
"enabled": true,
"fetch": "eager",
"autoimport": {
"@symfony/ux-live-component/dist/live.min.css": true
}
}
},
"@symfony/ux-turbo": {
"turbo-core": {
"enabled": true,
"fetch": "eager"
},
"mercure-turbo-stream": {
"enabled": false,
"fetch": "eager"
}
}
},
"entrypoints": []
}
File renamed without changes.
25 changes: 0 additions & 25 deletions assets/css/app.css

This file was deleted.

15 changes: 0 additions & 15 deletions assets/js/app.js

This file was deleted.

11 changes: 0 additions & 11 deletions assets/js/bootstrap.js

This file was deleted.

30 changes: 0 additions & 30 deletions assets/js/controllers.json

This file was deleted.

3 changes: 3 additions & 0 deletions assets/styles/app.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
4 changes: 4 additions & 0 deletions bin/console
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
use App\Kernel;
use Symfony\Bundle\FrameworkBundle\Console\Application;

if (!is_dir(dirname(__DIR__).'/vendor')) {
throw new LogicException('Dependencies are missing. Try running "composer install".');
}

if (!is_file(dirname(__DIR__).'/vendor/autoload_runtime.php')) {
throw new LogicException('Symfony Runtime is missing. Try running "composer require symfony/runtime".');
}
Expand Down
11 changes: 7 additions & 4 deletions compose.override.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,16 @@ services:
###> doctrine/doctrine-bundle ###
database:
ports:
- "5432:5432"
- "5432"
###< doctrine/doctrine-bundle ###

###> symfony/mailer ###
mailer:
image: schickling/mailcatcher
image: axllent/mailpit
ports:
- "1025:1025"
- "1080:1080"
- "1025"
- "8025"
environment:
MP_SMTP_AUTH_ACCEPT_ANY: 1
MP_SMTP_AUTH_ALLOW_INSECURE: 1
###< symfony/mailer ###
7 changes: 6 additions & 1 deletion compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,17 @@ services:

###> doctrine/doctrine-bundle ###
database:
image: postgres:${POSTGRES_VERSION:-15}-alpine
image: postgres:${POSTGRES_VERSION:-16}-alpine
environment:
POSTGRES_DB: ${POSTGRES_DB:-app}
# You should definitely change the password in production
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-!ChangeMe!}
POSTGRES_USER: ${POSTGRES_USER:-app}
healthcheck:
test: ["CMD", "pg_isready", "-d", "${POSTGRES_DB:-app}", "-U", "${POSTGRES_USER:-app}"]
timeout: 5s
retries: 5
start_period: 60s
volumes:
- database_data:/var/lib/postgresql/data:rw
# You may use a bind-mounted host directory instead, so that it is harder to accidentally remove the volume and lose all your data!
Expand Down
11 changes: 6 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
"doctrine/doctrine-migrations-bundle": "^3.2",
"doctrine/orm": "^2.17",
"elao/enum": "^2.0",
"knplabs/knp-paginator-bundle": "^6.3",
"league/commonmark": "^2.4",
"phpdocumentor/reflection-docblock": "^5.3",
"phpstan/phpdoc-parser": "^1.13",
"symfony/amazon-mailer": "7.1.*",
"symfony/asset": "7.1.*",
"symfony/asset-mapper": "7.1.*",
"symfony/console": "7.1.*",
"symfony/dotenv": "7.1.*",
"symfony/expression-language": "7.1.*",
Expand All @@ -39,14 +40,13 @@
"symfony/string": "7.1.*",
"symfony/translation": "7.1.*",
"symfony/twig-bundle": "7.1.*",
"symfony/ux-autocomplete": "^2.19",
"symfony/ux-chartjs": "^2.19",
"symfony/ux-live-component": "^2.19",
"symfony/ux-turbo": "^2.19",
"symfony/ux-twig-component": "^2.19",
"symfony/validator": "7.1.*",
"symfony/web-link": "7.1.*",
"symfony/webpack-encore-bundle": "^2.1",
"symfony/yaml": "7.1.*",
"symfonycasts/tailwind-bundle": "^0.6.0",
"tales-from-a-dev/flowbite-bundle": "^0.7",
"twig/extra-bundle": "^3.9",
"twig/intl-extra": "^3.9",
Expand Down Expand Up @@ -106,7 +106,8 @@
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
"assets:install %PUBLIC_DIR%": "symfony-cmd",
"importmap:install": "symfony-cmd"
},
"post-install-cmd": [
"@auto-scripts"
Expand Down
Loading

0 comments on commit f885b51

Please sign in to comment.