I'm doing a symfony backend integration with react frontend. I followed a tutorial guide and the official symfony documentation.
Try running the command yarn run encore dev --watch
to generate the corresponding transpile. I fail with the following error that I copy:
Entry module not found: Error: Can't resolve 'C:\Users\User_' in 'C:\xampp\htdocs\web_cotizacion_repuestos'
The webpack.config.js configuration file has the following form:
var Encore = require('@symfony/webpack-encore');
Encore
// Directorio donde se almacenarán los assets ya compilados.
.setOutputPath('public/build/')
.setPublicPath('/build')
// Nuestro archivo app.js, que será compilado y almacenado en /web/build/app.js
.addEntry('app', './assets/js/app.js')
// .addEntry('buscarRepuesto', './assets/js/Components/buscar repuesto/buscarRepuesto.js')
// Habilitar el mapeo de recursos en Desarrollo.
.enableSourceMaps(!Encore.isProduction())
// Borra el contenido del directorio /web/build antes de volver a compilar una nueva versión.
.cleanupOutputBeforeBuild()
// Muestra una notificación cuando se ha finalizado la compilación.
.enableBuildNotifications()
// Activa React
.enableReactPreset()
// .configureBabel(function(babelConfig) {
// // add additional presets
// babelConfig.presets.push('@babel/preset-flow');
// // no plugins are added by default, but you can add some
// babelConfig.plugins.push('styled-jsx/babel');
// }, {
// // node_modules is not processed through Babel by default
// // but you can whitelist specific modules to process
// includeNodeModules: ['foundation-sites'],
// // or completely control the exclude rule (note that you
// // can't use both "includeNodeModules" and "exclude" at
// // the same time)
// exclude: /bower_components/
// })
.copyFiles({
from: './assets/img',
// optional target path, relative to the output dir
to: 'images/[path][name].[ext]',
// if versioning is enabled, add the file hash too
//to: 'images/[path][name].[hash:8].[ext]',
// only copy files matching this pattern
pattern: /\.(png|jpg|jpeg)$/
})
;
// Exporta la configuración final
module.exports = Encore.getWebpackConfig();
Can anyone guide me on how to resolve this issue? Thank you very much!!!
I finally found the solution by modifying my webpack.config.js file so that it looks like this:
Previously clear the cache and update the node,npm,yarn packages. I leave you a link to a tutorial on REACT integration with SYMFONY, it is well explained and simple.