symfony / webpack-encore-bundle

Symfony integration with Webpack Encore!
https://symfony.com/webpack-encore
MIT License
933 stars 83 forks source link

Docs seem to be missing something ? #183

Open udf2457 opened 2 years ago

udf2457 commented 2 years ago

Apologies for the obscure title but I'm ramming my head against a brick wall here !

According to the docs, all you need to do is:

  1. composer require symfony/webpack-encore-bundle
  2. yarn install

But although the commands run successfully on my machine, the result is something that does not work. Because if we proceed further (as instructed "You can skip the rest of this article and go write your first JavaScript and CSS by reading Encore: Setting up your Project!"), we are told that we can run commands such as:

But this is evidently far from the truth:

yarn run v1.22.19 warning package.json: No license field error Command "build" not found. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Following internet searches, I have tried yarn install --production=false but it makes no difference. Equally running composer require webpack makes no difference and neither does recipes:install symfony/webpack-encore-bundle --force -v.

There is no node_modules/.bin/encore and package.json makes no mention of anything (it only lists my own @popperjs/core and bootstrap yarn additions).

So it seems somebody has been over-optimistic about the minimal steps required to get it working, and it would be nice to see the docs corrected accordingly !

My environment

yarn version v1.22.19 node v18.4.0 PHP 8.1.7 Debian bullseye

My symphony dir was created using composer create-project symfony/skeleton:"6.1.*" foobar and all yarn commands are being run within that directory (i.e. I'm not being silly and running it somewhere else)

maximehardy commented 1 year ago

Maybe the docs were not up to date when you created this issue, but here is the solution for the missing aliases dev, watch...:

Add the following into your package.json

"scripts": {
    "dev-server": "encore dev-server",
    "dev": "encore dev",
    "watch": "encore dev --watch",
    "build": "encore production --progress"
}