2

I'd like to know how I can extend angular-cli build process.

I want to add additional JSON file to /dist folder after cli finishes its work. I can't see a way to add any callback in angular-cli-build.js.

I tried:

var Angular2App = require( 'angular-cli/lib/broccoli/angular2-app' );
var ngCliVersion = require( './ng-cli-version' );

module.exports = function ( defaults ) {
  /* CREATE JSON FILE CONTAINS INFO ABOUT BUILD VERSION AND GIT COMMIT */
  ngCliVersion.createVersionFile();

  return new Angular2App( defaults, {
    vendorNpmFiles: [
      'systemjs/dist/system-polyfills.js',
      'systemjs/dist/system.src.js',
      'zone.js/dist/*.js',
      'core-js/client/shim.js',
      'reflect-metadata/*.js',
      'rxjs/**/*.js',
      '@angular/**/*.js'
    ]
  } );
};

The problem is that cli wipes dist folder before it starts so file I created is removed.

How then extend build process properly without hacking cli?

2
  • 2
    Just add your file to public/ folder, it will be copied to dist/ as is... Commented Jun 16, 2016 at 10:54
  • @Sasxa that is the correct approach to use here, can you please put that in the form of an answer so it can be accepted and found/used by others? Commented Jun 16, 2016 at 14:37

1 Answer 1

3

If you want to copy a file in build process, you just need to add it to the public/ folder and it will be copied to dist/ folder.

I couldn't find any documentation to quote here, other then this function in source files, but here's something from Ember CLI docs.

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

Comments

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.