Reputation: 33
I've a problem when I configure for the first time the webpack.config.js in my Symfony 3.4 project. I folow the documentation of symfony to install and configure encore but I don't know why I've allways this error:
$ yarn run encore dev
yarn run v1.6.0
$ [my_root_project_path]\node_modules\.bin\encore dev
Running webpack ...
ERROR Failed to compile with 1 errors10:01:31
error
Entry module not found: Error: Can't resolve 'web/build/app.js' in '[my_root_project_path]'
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
my webpack.config.js file is this:
// webpack.config.js
var Encore = require('@symfony/webpack-encore');
Encore
.setOutputPath('web/build/')
.setPublicPath('/build')
.addEntry('app', 'web/build/app.js')
.autoProvidejQuery()
.enableSourceMaps(!Encore.isProduction())
.cleanupOutputBeforeBuild()
;
module.exports = Encore.getWebpackConfig();
Does the problem come from a permission on files that Encore doesn't? Anyway, I'm lost, I don't know what to do.
Config:
Note: I know there is probably another post of the same kind of issue but I think that at the moment I have tested everything and my problem persists. I'm always listening and if you think there's a stackoverflow post that can solve my problem I'll let you share it with me.
Upvotes: 3
Views: 3033
Reputation: 376
Your problem is in addEntry path
.addEntry('app', 'web/build/app.js')
which does not point to the right file. The correct syntax is:
.addEntry(<name_of_the_entry>, <path_to_the_entry>)
where path_to_the_entry must point to a js file you want to add in your build, not directly to your build path. This file should be in a different folder e.g. 'your_project_root/assets/js/your_js_file.js' as specified in doc.
Encore will create the appropriate .js file (and possibly .css if you added one in your .js file) in your web/build folder so that your users can access those files.
Upvotes: 4