-
Notifications
You must be signed in to change notification settings - Fork 12k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
/public vs /src/assets behavior #1942
Comments
ico/faviocon files can be anywhere, the default location is usually the root, but you can change the locations in html. I consider robots and favicons web specific, not directly under the app scope. I would place them in the dist folder and commit those under git. If you must change this behavior, edit the angular-cli.json |
@robertbaker I've tried this. Turns out it doesn't work. But I think that this is a legitimate question of @splintercode. It should definetly be possible to add files like a |
This new behavior also affects our projects here. We have had to work around in the obvious hacky way, by building a build process around the CLI-provided build process which adds the files we need at the "root" of the output. I think most real projects will eventually have at least one, and often many, files that needs to be located somewhere in the "root" of the output - files that CLI doesn't know about and can't be responsible for. Until .webpack.3..8, this was supported and worked very well. I request the feature be put back and kept in the future also. |
I would be fine if the contents of |
Summary:
|
@kylecordes exactly, thank you, except:
|
If For example:
|
I really don't want a solution like @doggy8088 outlined, in which I need to... tell... CLI... about... each... and... every... file... I... want... to... include..... |
@doggy8088 I think thats unnecessary, because if the contents of
would be mapped to:
In my opinion a second Update I thought about it, and I think that the assets don't belong to # Configs, like before. And with that, I mean **all** configs,
# including angular-cli.json. Be consistent
config/
# distribution: compiled src/ and copied contents of resources/
dist/
# I'd rather have this in src/, since those are source files, aren't they?
e2e/
# images, global styles, robots.txt, .htaccess, who knows what,
# 1:1 mapped into dist/ on build
resources/
# source files, and with that, I mean source files and nothing else
# (no favicons or assets)
src/ |
@christiandreher Actually, I like the original |
That's exactly what I am saying. Like I already said, I just didn't like the name So in the end, you have a folder where you work ( |
|
This is preventing our team from upgrading to the latest CLI version as we have to have files in the root during development time. |
It shouldn't have anything to do with the "mode" we're in (development or production). Custom files need to be copied to |
@MrCroft correct, we have a workaround for a |
@splintercode oh, yeah... |
Looks like this bug was introduced with this changeset 3dcd49b |
+1 on bringing back public. It setup nicely for my bower dependencies (polymer) and a couple of others. Not sure what the official word on how to handle bower dependencies. |
@jjarrell50 for now, with webpack.8 at least, you can add styles (either css or even scss, if the app was initialized with But the problem with |
We need to have a way to copy some assets from, for instance, node_modules (maybe svg files or something else) What do you think ? |
Yes, like I've already said (and others as well, including @doggy8088), we definitely need the public functionality back (a possibility to have any kind of files - even an entire folder structure - copied over anywhere we'd need them, up to the root of dist, not just in a sub-folder). |
Per default, I would just copy the contents of For assets that are located in other directories, like |
Anyone looking for a temporary fix, especially for those needing .htaccess - in your
And this will copy over everything from |
To me it looks like @CodeJason's inbetween solution will break the compile on the second cycle of |
Sorry @sqwk I should have mentioned I had only tried it with ng build. It looks like any time after the first round of building, it overwrites |
Should I expect
they are not, even though my component-level |
@JanStureNielsen It's for static assets only. |
If you are using some kind of CI / build chain simply just copy the .htaccess. Here an example if for lftp (FTP)
|
I agree with @Meligy. I also am using IIS and require web.config file (btw, thanks for rewrite rules example @Meligy). I think these static files should be outside of src and should be called static which get written to root of dist folder. If there are subfolders in 'static', then they become subfolders of dist. Ideally, I'd like dist to contain subfolders for each environment as opposed to wiping out dist and starting over. If I do 'ng build' and 'ng build --prod', then dist would be: dist this allows me to compare different environments. Thanks for your time. |
@tomschreck just use the |
At least lets have the root public/assets/resources/static folder back for the shown scenarios please. |
@Meligy To get around the IIS issue (I am in the same situation) build your project into |
@christiandreher - thanks for the tip. good to know |
@splintercode I was planning on something like that until I realised: in this way I need a rewrite for the routes, and a rewrite for the script files and other assets. That won't work very well. The script tags in the HTML will be root (dist) relative because the browser thinks the HTML is served from the root when the rewrite happens, the script tags now will match nothing because there's nothing in root (dist), so, I'll need to have them rewritten not to Which sounds OK, until you think about client routes, those should not go to It then gets very complex, for something that I already had solved when the |
We realize that the change from The main motivations for
Point two presents a problem for any setup that copies stuff from a certain folder to the dist root. There's a number of solutions that we're considering, but I don't have any to share at the moment since we haven't decided what avenue to take. |
@filipesilva also referenced this: #2232 |
I was hosting bower references (polymer) into the public/bower_components
So i tried to redirect the reference to assets/bower_components. it didn't Can anybody confirm, that the move to assets is more than just a rename of |
Why are you using bower? You shouldn't need it anymore. Use 'npm i --save polymer' |
@robertbaker - you got me encouraged for a moment, but the NPM polymer is not the polymer I'm referring to. The one I'm referring https://www.polymer-project.org/1.0/ which happens to be a google project. The docs all say it's bower. It's much farther along, today than Angular2 Material Design. At this point, I'm looking any solution, I'm thinking about serving these dependencies CDN style, at least until I can figure a way to include them in my build. I'd generally expect support in angular-cli for polymer. They both come out of the googleverse after all. |
@filipesilva would it be too bold to ask what are the major downsides of the following approach?
I can think of a few questions you might ask
Are there other concerns with this approach compared to other approaches? It's the closest one to the old approach, which is proven valuable by many comments here. P.S. Thanks a lot for all your own voluntary efforts in this free tool |
Another workaround for those who need to include web.config into the prod build, here is another workaround that works. I simply added an entry for it in the assets section of angular-cli.json |
Thats no workaroound, @cheresier, thats how it is intended to work after the update. The issue is old, back then it was not possible to do that. |
Oh, cool. Sorry, Looks like I got the wrong idea looking through the thread that we are looking for a solution equivalent to the /public folder. |
Is there really no other way than typing every file into apps[0].assets? Eg. when using http://realfavicongenerator.net to generate the favicon files you get ~10 files - thats a lot of clutter to have in the root folder. (Not including .htaccess or web.config and robots.txt) |
@Nikkelmann There is nothing stopping you from putting your favicons into |
@robertbaker Sure, but the recommended way is to put the files in the root folder. http://realfavicongenerator.net/faq
|
angular/angular-cli#1942 this seems annoying
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Mac OSX El Capitan
ng --version
. If there's nothing outputted, please runin a Terminal:
node --version
and paste the result here:angular-cli: 1.0.0-beta.11-webpack.8
node: 5.10.1
os: darwin x64
The latest version of the cli replaces the
public
directory with the newsrc/assets
directory which works great for copying static files into dist but I'm not sure if the behavior is quite right. Many files are expected to be on the root of a hosted site such as robots.txt and ico files. When the cli copies files over from assets into the dist they are placed atdist\assets
. Is there any way to be able to copy files over to the root level of the dist?The text was updated successfully, but these errors were encountered: