Thanks for this great tool.
Maybe it would be more user-friendly if we can add "encore" to "scripts" in package.json by default.
"scripts": {
"encore": "./node_modules/.bin/encore"
},
So instead of typing ./node_modules/.bin/encore production, we can just type npm run encore production or yarn run encore production.
Hi @loceric,
That would need to be in the package.json file of the project using Encore. I don't think we can (nor should) modify it.
That being said, it should not be necessary if you use yarn (which is the recommended way to go): you can already do yarn run encore production (or even yarn encore production) as explained in the yarn run documentation:
[script]can also be any locally installed executable that is insidenode_modules/.bin/.
By the way, if you add your own scripts you don't need to put the whole ./node_modules/.bin/ part, it is already handled by both npm and yarn, so the following would work:
{
"scripts": {
"build:dev": "encore dev",
"build:prod": "encore production"
}
}
putting the whole path even harms you, because the full path is not the same on Windows or Unix (while relying on the PATH works fine, as the directory separator difference now happens inside npm/yarn rather than inside your package.json)
Thanks so much for the information, Lyrkan and stof.
Maybe for people like me, who is still learning Node, the Symfony document at (http://symfony.com/doc/current/frontend/encore/simple-example.html) could be a little confusing.
If we can just run yarn encore production, can we replace the ./node_modules/.bin/encore production command in that document?
+1 I think I'd prefer the yarn encore production style in the docs. Actually, I didn't know you could do this :).
yarn encore production works for now but I can't find a mention of this behavior in the documentation of yarn (even if it's quite clear that's intended: https://github.com/yarnpkg/yarn/blob/master/src/cli/index.js#L105-L109).
Maybe it would be safer to put yarn run encore production in the docs?
Most helpful comment
putting the whole path even harms you, because the full path is not the same on Windows or Unix (while relying on the PATH works fine, as the directory separator difference now happens inside npm/yarn rather than inside your package.json)