Skip to content

Commit

Permalink
build task refactored
Browse files Browse the repository at this point in the history
  • Loading branch information
b091 committed Jan 8, 2016
1 parent 21fd05e commit bfd9273
Showing 1 changed file with 23 additions and 19 deletions.
42 changes: 23 additions & 19 deletions tasks/build.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
module.exports = (gulp, config) => {
return () => {
const path = require('path');
const appName = require(path.join(config.projectDir, 'package.json')).name;
const Builder = require('jspm').Builder;
module.exports = (gulp, config) => () => {
const path = require('path');
const Builder = require('jspm').Builder;
const builder = new Builder();

return beginBuild()
.then(buildSFX)
.catch((err) => console.log('Build Failed', err));

function beginBuild() {
builder.reset();
return builder.loadConfig(path.join(config.projectDir, 'jspm.conf.js'))
}

const builder = new Builder();
function buildSFX() {
const appName = require(path.join(config.projectDir, 'package.json')).name;
const distFileName = `${appName}.min.js`;
const outFile = path.join(config.distDir, distFileName);
const moduleName = 'app';
const buildConfig = {
format: 'amd',
minify: true,
sourceMaps: true
};
return builder.buildStatic(moduleName, outFile, buildConfig);
}

builder.reset();
builder.loadConfig(path.join(config.projectDir, 'jspm.conf.js'))
.then(() => {
const moduleName = 'app';
const buildConfig = {
format: 'amd',
minify: true,
sourceMaps: true
};
return builder.buildStatic(moduleName, outFile, buildConfig);
})
.catch((err) => console.log('Build Failed', err));
};
};

0 comments on commit bfd9273

Please sign in to comment.