Skip to content

Instantly share code, notes, and snippets.

@darkslategrey
Created December 15, 2016 17:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darkslategrey/0a72c0e4d53c52ecd7a334908751e34c to your computer and use it in GitHub Desktop.
Save darkslategrey/0a72c0e4d53c52ecd7a334908751e34c to your computer and use it in GitHub Desktop.
const gulp = require('gulp');
const replace = require('gulp-replace');
const Builder = require('jspm').Builder;
const conf = require('../conf/gulp.conf');
gulp.task('systemjs', systemjs);
gulp.task('systemjs:html', updateIndexHtml);
function systemjs(done) {
const builder = new Builder('./', 'jspm.config.js');
builder.config({
paths: {
"github:*": "jspm_packages/github/*",
"npm:*": "jspm_packages/npm/*"
},
packageConfigPaths: [
'npm:@*/*.json',
'npm:*.json',
'github:*/*.json'
]
});
builder.buildStatic(
`${conf.path.src('index.ts')} + ${conf.path.tmp('templateCacheHtml.ts')}`,
conf.path.tmp('index.js'),
{
production: true,
browser: true
}
).then(() => {
done();
}, done);
}
function updateIndexHtml() {
return gulp.src(conf.path.src('index.html'))
.pipe(replace(
/<script src="jspm_packages\/system.js">[\s\S]*System.import.*\n\s*<\/script>/,
`<script src="index.js"></script>`
))
.pipe(gulp.dest(conf.path.tmp()));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment