I am developing an express based web application and I started following the application skeleton built by express-generator.
Next, I added to my project webpack to bundle the client side assets.
Now I am not sure where to place the front-end javascript files, if in a /src
or /app
folder?
In truth, I am in a dilemma between, app.js
, /lib
, /src
and /app
folders.
According to express-generator, it creates an
app.js
file as the main entry and thus it looks a little bit strange to have anapp
folder with same name of the entry pointapp.js
.webpack usage manual suggests a
/src
folder to place javascript files. But I think/src
should not be exclusively for front-end javascripts and on the other hand, I would not like to mix both server and front-end javascript files in same folder.Moreover, the Accepted Answer to the question Folder structure for a Node.js project, contradicts the previous point because it states:
/src contains all your server-side specific CoffeeScript files
So, I think that maybe /src
is not the better option to place front-end javscript files and according to the Accepted answer to the question Node.js project naming conventions for files & folders I would follow the proposed structure:
/app - front-end javascript files
/bin - helper scripts
/lib - back-end express files
But is it ok to have a folder /app
and a file app.js
with same name? Furthermore, /app
is related with front-end and app.js
with back-end.
I would suggest you to just rename your main file from
app.js
toindex.js
and keep the structure proposed in Node.js project naming conventions for files & folders:Thus, there is no more misleading between
/app
folder related to front-end and theindex.js
, which is the back-end entry point.