require('shelljs/global');

const package = require('../package.json');
const prodDependencies = Object.keys(package.jspm.dependencies);
const devDependencies = Object.keys(package.jspm.devDependencies);
const allDependencies = prodDependencies.concat(devDependencies);

const command = process.argv[2];

switch (command) {
  case 'dev':
    exec(
      `jspm bundle ${allDependencies.join(' + ')} temp/vendor.dev.js -d`
    );
    break;

  case 'vendor':
    exec(
      `jspm bundle ${prodDependencies.join(' + ')} dist/vendor.prod.js -ms`
    );
    cp(
      '-R', ['jspm.config.js', 'jspm_packages/system.js'], 'dist'
    );
    break;

  case 'app':
    cp('assets/*', 'dist');
    exec(
      `jspm build src/app - ${prodDependencies.join(' - ')} dist/app.js --skip-source-maps --minify`
    );
    break;

  case 'debug':
    exec(
      `jspm build src/app - ${prodDependencies.join(' - ')} dist/app.js`
    );
    break;

  default:
    console.log('\nUsage: node build.js <arg>');
    console.log('\nwhere <arg> is one of:');
    console.log('    dev, app, vendor, debug\n');
    break;
}


require('shelljs/global');

const package = require('../package.json');
const prodDependencies = Object.keys(package.jspm.dependencies);
const devDependencies = Object.keys(package.jspm.devDependencies);
const allDependencies = prodDependencies.concat(devDependencies);

const command = process.argv[2];

switch (command) {
  case 'dev':
    exec(
      `jspm bundle ${allDependencies.join(' + ')} temp/vendor.dev.js -d`
    );
    break;

  case 'vendor':
    exec(
      `jspm bundle ${prodDependencies.join(' + ')} dist/vendor.prod.js -ms`
    );
    cp(
      '-R', ['jspm.config.js', 'jspm_packages/system.js'], 'dist'
    );
    break;

  case 'app':
    exec(
      `jspm build src/app - ${prodDependencies.join(' - ')} dist/app.js --skip-source-maps --minify`
    );
    cp('assets/*', 'dist');
    break;

  case 'debug':
    exec(
      `jspm build src/app - ${prodDependencies.join(' - ')} dist/app.js`
    );
    break;

  default:
    console.log('\nUsage: node build.js <arg>');
    console.log('\nwhere <arg> is one of:');
    console.log('    dev, app, vendor, debug\n');
    break;
}


Copy assets after dist folder has been created
Copy assets after dist folder has been created

The production build script fails when it tries to copy the content of the assets folder to a non-existing folder.