0

I am running Angular 4 using Angular CLI and I am looking for a way to copy files from a component directory to the assets folder at run time.

So given the following folder structure:

/component my.component.* /images image1.png image2.png 

When I run ng serve or ng build I would like to have these files copied to the assets folder to be served up and available in the browser.

Is there a way to accomplish this? I've been searching for quite a while and am yet to find a solution.

1 Answer 1

1

I guess you want to put those images in that folder for some personal preference? If they ultimately need to be in the assets folder at run time why not just put them there to start with? In your assets folder you could break them up into groups with folders that match your component structure.

It just doesn't seem like what you are trying to do is necessary.

To accomplish this I believe you would have to eject your project and then alter the entire build process to get this functionality. I don't believe the default angular CLI provides any mechanism to do this.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the answer. This is necessary because we need the images to be part of the package create by the ng build command. So there is no way to accomplish this that you are aware of?
ng build creates a dist folder. Inside this dist folder will be your assets folder that includes all the files that were in it during development. The assets folder is meant to hold all those static files that will be carried over into production.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.