ATTENTION: Testé fonctionnel (moyennant mes ajustements ci-dessous) sur les bases de la demo officielle de Pimcore qui tournait, au moment de mes tests, sous Pimcore v6.8.10. Source: msenkpiel.de – Using Symfony Webpack-Encore-Bundle with Pimcore et version PDF pour la postérité.
- Doc officielle Symfony/Webpack Encore: Encore: Setting up your Project
- Symfony5: The Fast Track (is the best book to learn modern Symfony development, from zero to production. +300 pages showcasing Symfony with Docker, APIs, queues & async tasks, Webpack, SPAs, etc.): Step 22: Styling the User Interface with Webpack
Résoudre l’erreur Could not find the entrypoints file from Webpack: the file « /var/www/html/web/build/entrypoints.json » does not exist.
Attention à bien vérifier les deux fichiers suivants par rapport à ce qui est indiqué dans le billet de blog de référence. J’ai eu une erreur Could not find the entrypoints file from Webpack: the file « /var/www/html/web/build/entrypoints.json » does not exist. en respectant à la lettre ce qui est indiqué. En modifiant les deux fichiers ci-dessous conformément à ce que je décris, ça a fonctionné.
webpack.config.js
/pimcore-demo/webpack.config.js. Attention au paramètre .setOutputPath()
pour lequel il faut mettre 'web/build'
(et non pas 'public/build'
.
Attention, si vous utilisez le skeleton officiel de Pimcore le paramètre .setOutputPath('public/build')
sera peut-être valide (pas testé)…
1 2 3 4 5 6 7 |
Encore // directory where compiled assets will be stored .setOutputPath('web/build/') // public path used by the web server to access the output path .setPublicPath('/build') // only needed for CDN's or sub-directory deploy //.setManifestKeyPrefix('build/') |
config.yml
/pimcore-demo/app/config/config.yml
1 2 3 4 5 6 7 |
#### SYMFONY OVERRIDES framework: assets: json_manifest_path: '%kernel.project_dir%/web/build/manifest.json' webpack_encore: output_path: '%kernel.project_dir%/web/build' |
Remarque: nous avons /pimcore-demo/config/packages/assets/assets.yaml qui contient aussi une référence au dossier public/. Je ne l’ai pas modifié lors de mon test.
1 2 3 |
framework: assets: json_manifest_path: '%kernel.project_dir%/public/build/manifest.json' |
Ajout des liens vers les fichiers compilés dans un template Twig
Attention: veiller à bien positionner l’appel à la source JS juste avant la fermeture du tag </body>
. Sinon on peut avoir des problèmes à l’exécution de certains JS, comme par exemple avec l’exemple d’intégration du framework UIkit avec Webpack ou j’obtenais une erreur cannot read property appendChild of undefined.
1 2 3 4 |
{% block javascripts %} {{ encore_entry_script_tags('app') }} {% endblock %} </body> |