3

Hi I have some static files that I need copied to the root of the apps dist dir (not in myapp/dist/assets) Is there way to configure the angular.json file to do this during a ng build?

angular v 6.0.3

3
  • You can easily do it with a custom script which you can run after ng build. I don't think that ng has an option for this. Commented Aug 30, 2018 at 14:29
  • 1
    Add them to the root of the project, and define them as assets within angular.json, just like favicon.ico is by default. No need for a script Commented Aug 30, 2018 at 15:03
  • favicon does not end up in the dist root - It ends up in the root of whatever language folder you have. Ie dist only contains folders 'en' and 'de' where favicon will be in the root of both folders but there are no default files in the dist root! ng12. If you only have one language then yes, placing it in angular.json works. Commented Oct 12, 2021 at 14:36

1 Answer 1

3

You need to add script commands inside package.json.

scripts: {
"copyAssets": "cp -r src/assets/* dist/assets/ || copy /Y src/assets/* dist/assets/ ",
}

You can include 'npm run copyAssets' in the build script.

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

1 Comment

Still valid for ng12 - Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.