Creating a new webapp in symfony 7 lead me to compile error while attempting to build assets with webpack.
ERROR Failed to compile with 1 errors
00:13:02 Module build failed: Module not found:"./assets/bootstrap.js" contains a reference to the file "@symfony/stimulus-bundle". This file can not be found, please check it for typos or update it if the file got moved.
It's seems that it's due to the AssetMapper which is installed by default when creating a new webapp project.
If you prefer to use webpack to manage your assets, follow the link below to the documentation to switch from AssetMapper to Webpack properly :
https://symfony.com/doc/current/frontend.html#switch-from-assetmapper
Solution :
It's seems that it's due to the AssetMapper which is installed by default when creating a new webapp project.
If you prefer to use webpack to manage your assets, follow the link below to the documentation to switch from AssetMapper to Webpack properly :
https://symfony.com/doc/current/frontend.html#switch-from-assetmapper
#Remove AssetMapper & Turbo/Stimulus temporarily
composer remove symfony/ux-turbo symfony/asset-mapper symfony/stimulus-bundle
# Add Webpack Encore and Turbo/Stimulus back
composer require symfony/webpack-encore-bundle symfony/ux-turbo symfony/stimulus-bundle
# Install and build assets
npm install
npm run dev