StephenRios
StephenRios

Reputation: 2242

Automatically copy images to assets folder

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.

Upvotes: 0

Views: 943

Answers (1)

jLee
jLee

Reputation: 483

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.

Upvotes: 1

Related Questions