Skip to content

Commit

Permalink
chore(*) add gulp build --env test
Browse files Browse the repository at this point in the history
You can build your app with the test configuration (using stubs/mocks ...)
Just use `gulp build --env test`
Like all the `gulp build` tasks:
* Your bundled app will land in `build/dist` folder
* You'll be able to launch it via `gulp serve --env prod` (yeah it's a bit tricky but you
understand)
  • Loading branch information
topheman committed Aug 23, 2015
1 parent c93d3f0 commit e97b4cd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
21 changes: 18 additions & 3 deletions gulp/tasks/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import util from 'gulp-util';
import gulp from 'gulp';
import jshint from 'gulp-jshint';
import cache from 'gulp-cache';
import footer from 'gulp-footer';
import gulpif from 'gulp-if';

import {ENV} from '../utils.js';
import {LOG,COLORS,ENV} from '../utils.js';
import paths from '../paths';

/**
Expand All @@ -32,17 +34,30 @@ gulp.task('jshint', () => {
.pipe(jshint.reporter('fail'));
});

gulp.task('jspmconfig', () => {
var injection;
if(ENV === 'test'){
var jspmOverride = require(paths.test.config.jspmOverride);
LOG(COLORS.yellow('[INFOS] Using jspm.override.json:'))
var injection = "System.config("+JSON.stringify(jspmOverride)+")";
LOG(COLORS.yellow(injection));
}
return gulp.src(paths.config.jspm)
.pipe(gulpif(ENV === 'test', footer(injection)))
.pipe(gulp.dest(paths.tmp.config.basePath));
});

/**
* Create JS production bundle.
*/
gulp.task('bundle', ['jshint'], (cb) => {
gulp.task('bundle', ['jshint', 'jspmconfig'], (cb) => {
const Builder = require('systemjs-builder');
const builder = new Builder();
const inputPath = 'src/app/bootstrap';
const outputFile = paths.tmp.scripts + 'app.bootstrap.build.js';
const outputOptions = {sourceMaps: true, config: {sourceRoot: paths.tmp.scripts}};

builder.loadConfig('./jspm.config.js')
builder.loadConfig(paths.tmp.config.jspm)
.then(() => {
builder.buildSFX(inputPath, outputFile, outputOptions)
.then(() => {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"gulp-footer": "^1.0.5",
"gulp-header": "^1.2.2",
"gulp-htmlhint": "^0.3.0",
"gulp-if": "^1.2.5",
"gulp-imagemin": "^2.3.0",
"gulp-inject": "^1.5.0",
"gulp-jshint": "^1.11.0",
Expand Down

0 comments on commit e97b4cd

Please sign in to comment.