Skip to content

Commit

Permalink
Replace Asset mapper with Webpack temp
Browse files Browse the repository at this point in the history
  • Loading branch information
codedmonkey committed Jul 29, 2024
1 parent 0a10307 commit 063da29
Show file tree
Hide file tree
Showing 13 changed files with 243 additions and 134 deletions.
10 changes: 6 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
.phpunit.result.cache
###< phpunit/phpunit ###

###> symfony/asset-mapper ###
/assets/vendor/
/public/assets/
###< symfony/asset-mapper ###
###> symfony/webpack-encore-bundle ###
/node_modules/
/public/build/
npm-debug.log
yarn-error.log
###< symfony/webpack-encore-bundle ###
8 changes: 4 additions & 4 deletions assets/app.js
Original file line number Diff line number Diff line change
@@ -1,9 +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.
* We recommend including the built version of this JavaScript file
* (and its CSS file) in your base layout (base.html.twig).
*/
import './styles/app.css'

console.log('This log comes from assets/app.js - welcome to AssetMapper! 🎉')
// any CSS you import will output into a single css file (app.css in this case)
import './styles/app.css';
2 changes: 1 addition & 1 deletion assets/styles/app.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
body {
background-color: skyblue;
background-color: lightgray;
}
5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"phpstan/phpdoc-parser": "^1.24",
"sentry/sentry-symfony": "^5.0",
"symfony/asset": "^7.0",
"symfony/asset-mapper": "^7.0",
"symfony/console": "^7.0",
"symfony/doctrine-messenger": "^7.0",
"symfony/dotenv": "^7.0",
Expand All @@ -46,6 +45,7 @@
"symfony/twig-bundle": "^7.0",
"symfony/validator": "^7.0",
"symfony/web-link": "^7.0",
"symfony/webpack-encore-bundle": "^2.1",
"symfony/yaml": "^7.0",
"symfonycasts/reset-password-bundle": "^1.22",
"twig/extra-bundle": "^2.12|^3.0",
Expand Down Expand Up @@ -87,8 +87,7 @@
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd",
"importmap:install": "symfony-cmd"
"assets:install %PUBLIC_DIR%": "symfony-cmd"
},
"post-install-cmd": [
"@auto-scripts"
Expand Down
152 changes: 72 additions & 80 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions config/bundles.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
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],
SymfonyCasts\Bundle\ResetPassword\SymfonyCastsResetPasswordBundle::class => ['all' => true],
Twig\Extra\TwigExtraBundle\TwigExtraBundle::class => ['all' => true],
];
5 changes: 0 additions & 5 deletions config/packages/asset_mapper.yaml

This file was deleted.

45 changes: 45 additions & 0 deletions config/packages/webpack_encore.yaml
Original file line number Diff line number Diff line change
@@ -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
21 changes: 0 additions & 21 deletions importmap.php

This file was deleted.

21 changes: 21 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "@codedmonkey/conductor-assets",
"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"
}
}
31 changes: 16 additions & 15 deletions symfony.lock
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,6 @@
"config/packages/sentry.yaml"
]
},
"symfony/asset-mapper": {
"version": "7.0",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "6.4",
"ref": "8a0d17c04c791b3d7bdd083e1e2b2a53439dc3b0"
},
"files": [
"assets/app.js",
"assets/styles/app.css",
"config/packages/asset_mapper.yaml",
"importmap.php"
]
},
"symfony/console": {
"version": "7.0",
"recipe": {
Expand Down Expand Up @@ -292,6 +277,22 @@
"config/packages/messenger.yaml"
]
},
"symfony/webpack-encore-bundle": {
"version": "2.1",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "2.0",
"ref": "082d754b3bd54b3fc669f278f1eea955cfd23cf5"
},
"files": [
"assets/app.js",
"assets/styles/app.css",
"config/packages/webpack_encore.yaml",
"package.json",
"webpack.config.js"
]
},
"symfonycasts/reset-password-bundle": {
"version": "1.22",
"recipe": {
Expand Down
3 changes: 2 additions & 1 deletion templates/base.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +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></svg>">
{% block stylesheets %}
{{ encore_entry_link_tags('app') }}
{% endblock %}

{% block javascripts %}
{% block importmap %}{{ importmap('app') }}{% endblock %}
{{ encore_entry_script_tags('app') }}
{% endblock %}
</head>
<body>
Expand Down
Loading

0 comments on commit 063da29

Please sign in to comment.