Created
December 15, 2016 17:52
-
-
Save darkslategrey/0a72c0e4d53c52ecd7a334908751e34c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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