fumeapp / laranuxt

Laravel and Nuxt.js boilerplate
658 stars 136 forks source link

Suggestion: Dont integrate nuxt code into resources directory #6

Closed connecteev closed 4 years ago

connecteev commented 5 years ago

@acidjazz One suggestion here: Dont integrate nuxt code into resources directory Keeping the laravel resources directory kosher allows one to run as separate processes and involve different tech in separate directories - just to make it easier for anybody looking into this code to see where the boundaries are (it also makes managing deployments easier for example).

Proposed folder structure:

By extension, the nuxt.config.js and tailwind.config.js shouldn't be in the laravel config/ folder. Better if all front-end (nuxt) assets are in the same (proposed name: "client") directory.

acidjazz commented 5 years ago

Thanks @connecteev I'll consider it,

BTW this folder is specified as NUXT_ROOT in your .env file, so it should be easy to change if you template off of this boilerplate.

client/ isn't a bad idea, but I thought it was ok design to share config/ since they are both sharing .env ?

connecteev commented 5 years ago

@acidjazz interesting, I didn't know this was configurable. However, unless there's an obvious advantage I am missing, I do believe that a separation of front-end and back-end (versus a tight coupling) is a better design...just my 2c!

So, I think having the default nuxt directory not clash with the laravel resources folder is a good architecture, so it's not as tightly coupled. You can then deploy to these codebases separately, even. I would suggest moving the nuxt files to either a "client" or "nuxt" folder, and it can live at the top-level.

As far as the config is concerned, the front-end should all live in one place, and that includes the nuxt.config.js and tailwind.config.js files, since they fall under the purview of "front end". So they shouldn't be in the laravel config/ folder. Better if all front-end (nuxt) assets are in the same (proposed name: "client") directory.

As far as the .env file is concerned, it is owned by Laravel, and it should be focused on back-end only.

Summarizing: If you're open to it, can I suggest the following:

  1. Move the nuxt.config.js and tailwind.config.js out of the laravel config/ folder and into the nuxt "client" folder.
  2. Get rid of the NUXT_ROOT=resources setting (Laravel doesn't need to know where the nuxt / client folder is, and the default routes and view files put in resources/views should still work if the laravel routes are defined above / override the catch-all nuxt route.
  3. Unclear, do we need APP_API? Doesnt the front-end already know where it's running / located (port 3000 in this case)?
    APP_API=http://localhost:3000/api
    config/nuxt.config.js:    baseURL: process.env.APP_API,
  4. Also do we need to define APP_PROXY=http://localhost:8000/ Why can it not use APP_URL instead, or do we expect the 2 settings to be different? If possible, I would get rid of APP_PROXY and use APP_URL like so:
    config/nuxt.config.js:    '/api': { target: process.env.APP_URL, ws: true },
    config/nuxt.config.js:    '/_debugbar': process.env.APP_URL + '_debugbar',

These are just suggestions, of course...and I've only been playing with nuxt for a few days...but these suggestions come from a design standpoint for better more maintainable code, so I'll let you make the final call!

acidjazz commented 5 years ago

@connecteev this is all pretty new and still kind of experimented on.. although i do have two huge projects under this now it seems to be pretty solid so far, i don't have any solid answers for the config setup just yet.

go ahead and try out what I just checked in, a lot leaner.

connecteev commented 5 years ago

@acidjazz New code looks clean...if you got rid of bulma, might make sense to delete the bulma.css and bulma.sass files as well.

And I'll let you consider the suggestions above for the config setup..just my 2c. Btw what projects do you have running, mind sharing some links? Inspiration is always great.

acidjazz commented 5 years ago

@connecteev i wish i could but both are private :(

thanks! I'lll go ahead and remove those as well.

acidjazz commented 4 years ago

@connecteev BTW i have a whole new version up now that does not limit nuxtjs to a single directory, LMK what you think

acidjazz commented 4 years ago

BTW @connecteev I also went w/ your recommendation of client/ and going w/ the srcDir: parameter this time

connecteev commented 4 years ago

@acidjazz thats great. I'm using vanilla nuxt and laravel at the moment in separate folders, I will come back and give your repo a try shortly.

acidjazz commented 4 years ago

@connecteev i did that for a while, nbd. I do like sharing the .env though