Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

Make it easier to load resources in production #362

Open
FREEZX opened this issue Jan 14, 2015 · 10 comments
Open

Make it easier to load resources in production #362

FREEZX opened this issue Jan 14, 2015 · 10 comments

Comments

@FREEZX
Copy link

FREEZX commented Jan 14, 2015

In the current state of the project, when you build the application (mincss+uglify), the minified results are placed in the public/dist folder.
If you were using relative paths for images, fonts and such in css files, (which in my opinion is a logical solution, instead of writing /modules/something in front of every resource needed), your app won't load resources due to different paths of minified css and the actual path of resources.
For this type of thing to work, it is much needed for the build script to also copy all other resource files to the dist folder with their original file structure, and also putting the minified css to public/dist/css folder.

This should work out of the box, instead of having to manually change paths in all css files or moving files around manually.

@ilanbiala
Copy link
Member

The easier solution would be to create a dist folder in each module and place CSS/JS there, but that is something that can be changed by the user. I don't see an issue with us changing it as long as most people are in favor of the change.

@FREEZX
Copy link
Author

FREEZX commented Jan 14, 2015

in my config i added a base path that should point to the base url of the CDN, and i added a base tag in the main layout file.
Now, because the minified css is inside the dist folder, i changed it's build destination to dist/css, added a grunt task to copy everything from modules/*/img/ into dist/img so the relative paths in the css files can work (../img/pic.png). I made a copy task that copies everything from public/lib/ to dist/lib/, and another one that copies all angular html templates with the original folder structure into dist/.
By doing things this way i'm sure that the dist folder contains everything that should be put on CDN and everything should load correctly, although the solution is not perfect.

@ilanbiala
Copy link
Member

@codydaig @mleanos any thoughts on this? Not much in our implementation has changed, but loading resources is always something we should try to improve imo. I also want to see if you guys have any thoughts on whether this is really holding anything back or we should just close and come back to it when we do a much larger refactor.

@codydaig
Copy link
Member

@ilanbiala I honestly hadn't though much about this because I don't actually MEAN in production. However, I do think this may be a little bigger of a priority if it causes issues in the production environment. @mleanos thoughts? You've had experience in production.

@codydaig codydaig reopened this Oct 27, 2015
@lirantal
Copy link
Member

This topic is definitely an important issue to handle.
Would anyone like to review how we can approach a similar production build (dist directory) for this?

cc @codydaig @mleanos @ilanbiala @FREEZX

@FREEZX
Copy link
Author

FREEZX commented Aug 29, 2016

On the project i had worked on, what i said i did in my last comment is still in place and works well enough.

@lirantal
Copy link
Member

@FREEZX is it open source? can you show us an example of such implementation?
are you able to offer a PR?

@lirantal
Copy link
Member

@FREEZX also see my suggestion for the dist/ directory here: #1087 (comment)

@FREEZX
Copy link
Author

FREEZX commented Aug 31, 2016

@lirantal No, it's not open source unfortunately.
I also have this on my own framework which might prove useful:
https://github.com/FREEZX/nuke.js/blob/master/build.js
What it does is it goes through all the CSS files, finds all resources they use and copies them together with the minified css files.

@lirantal
Copy link
Member

lirantal commented Sep 1, 2016

Ok, saw it.
I think there's probably a better and more intuitive way of doing it with existing tools in gulp so if we don't have a PR for this I'll close it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants