/*
  This provides a standard way to reference
  project files from the build files without
  hardcoding too much into config
*/

const path = require('path');
const pkgpath = require('packpath');

const { directories, baseUrl: packageBaseUrl } = require(path.resolve(pkgpath.self(), 'package.json')); // eslint-disable-line
const source = (...paths) => path.resolve(pkgpath.self(), directories.source, ...paths);
const dest = (...paths) => path.resolve(pkgpath.self(), directories.dest, ...paths);

// dev always serves from root (localhost:8080),
// so only use baseUrl if task is not dev-related
const devTasks = ['dev', 'build:dev', 'test:dev'];
const baseUrl = devTasks.includes(process.env.npm_lifecycle_event) ? '/' : process.env.BASE_URL || packageBaseUrl || '/';


// This takes a simple object of entry:filepath pairs
// and runs each filepath through the source() helper
const sourceAll = (entry) =>
  Object.keys(entry)
    .reduce((entries, key) => {
      entries[key] = source(entry[key]);
      return entries;
    }, {});


module.exports = {
  baseUrl,
  source,
  dest,
  sourceAll
};

@@ -191,16 +191,55 @@
 ath');%0A%0A
+// grab what we need from package.json%0A
 const %7B 
@@ -361,461 +361,573 @@
 ine%0A
-const source = (...paths) =%3E path.resolve(pkgpath.self(), directories.source, ...paths);%0Aconst dest = (...paths) =%3E path.resolve(pkgpath.self(), directories.dest, ...paths);%0A%0A// dev always serves from root (localhost:8080),%0A// so only use baseUrl if task is not dev-related%0Aconst devTasks = %5B'dev', 'build:dev', 'test:dev'%5D;%0Aconst baseUrl = devTasks.includes(process.env.npm_lifecycle_event) ? '/' : process.env.BASE_URL %7C%7C packageBaseUrl %7C%7C '/';%0A
+%0A// check if base url is defined in package or command,%0A// return root if undefined or dev task is being run%0Aconst getBaseUrl = (devTasks) =%3E %7B%0A  if (devTasks && devTasks.includes(process.env.npm_lifecycle_event)) %7B%0A    return '/';%0A  %7D%0A%0A  return process.env.BASE_URL %7C%7C packageBaseUrl %7C%7C '/';%0A%7D;%0A%0A// define paths for export%0Aconst source = (...paths) =%3E path.resolve(pkgpath.self(), directories.source, ...paths);%0Aconst dest = (...paths) =%3E path.resolve(pkgpath.self(), directories.dest, ...paths);%0Aconst baseUrl = getBaseUrl(%5B'dev', 'build:dev', 'test:dev'%5D);
 %0A%0A// 
-T
+t
 his 

improve readability of paths-helper.js