-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Introduce build system based on Gulp #435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,6 @@ | ||
| FROM node:6.9 | ||
| MAINTAINER Paris Kasidiaris <[email protected]> | ||
|
|
||
| # Install cpio, used for building | ||
| RUN apt-get update \ | ||
| && apt-get install -y --no-install-recommends cpio \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # Set the working directory | ||
| WORKDIR /usr/src/app | ||
|
|
||
|
|
||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| const browserify = require('browserify'); | ||
| const buffer = require('vinyl-buffer'); | ||
| const fs = require('fs-extra'); | ||
| const gulp = require('gulp'); | ||
| const merge = require('merge-stream'); | ||
| const sorcery = require('sorcery'); | ||
| const source = require('vinyl-source-stream'); | ||
| const sourcemaps = require('gulp-sourcemaps'); | ||
| const ts = require('gulp-typescript'); | ||
| const tsify = require('tsify'); | ||
|
|
||
|
|
||
| let buildDir = process.env.BUILD_DIR || 'build'; | ||
|
|
||
|
|
||
| /** | ||
| * Compile TypeScript sources to JavaScript files and create a source map file for each TypeScript | ||
| * file compiled. | ||
| */ | ||
| gulp.task('tsc', function () { | ||
| // Remove the lib/ directory to prevent confusion if files were deleted in src/ | ||
| fs.emptyDirSync('lib'); | ||
|
|
||
| // Build all TypeScript files (including tests) to lib/, based on the configuration defined in | ||
| // `tsconfig.json`. | ||
| let tsProject = ts.createProject('tsconfig.json'); | ||
| let tsResult = tsProject.src().pipe(sourcemaps.init()).pipe(tsProject()); | ||
| let tsc = tsResult.js.pipe(sourcemaps.write('.', {includeContent: false, sourceRoot: ''})).pipe(gulp.dest('lib')); | ||
|
|
||
| // Copy all addons from src/ to lib/ | ||
| let copyAddons = gulp.src('src/addons/**/*').pipe(gulp.dest('lib/addons')); | ||
|
|
||
| // Copy stylesheets from src/ to lib/ | ||
| let copyStylesheets = gulp.src('src/**/*.css').pipe(gulp.dest('lib')); | ||
|
|
||
| return merge(tsc, copyAddons, copyStylesheets); | ||
| }); | ||
|
|
||
| /** | ||
| * Bundle JavaScript files produced by the `tsc` task, into a single file named `xterm.js` with | ||
| * Browserify. | ||
| */ | ||
| gulp.task('browserify', ['tsc'], function() { | ||
| // Ensure that the build directory exists | ||
| fs.ensureDirSync(buildDir); | ||
|
|
||
| let browserifyOptions = { | ||
| basedir: buildDir, | ||
| debug: true, | ||
| entries: ['../lib/xterm.js'], | ||
| standalone: 'Terminal', | ||
| cache: {}, | ||
| packageCache: {} | ||
| }; | ||
| let bundleStream = browserify(browserifyOptions) | ||
| .plugin(tsify) | ||
| .bundle() | ||
| .pipe(source('xterm.js')) | ||
| .pipe(buffer()) | ||
| .pipe(sourcemaps.init({loadMaps: true, sourceRoot: '..'})) | ||
| .pipe(sourcemaps.write('./')) | ||
| .pipe(gulp.dest(buildDir)); | ||
|
|
||
| // Copy all add-ons from lib/ to buildDir | ||
| let copyAddons = gulp.src('lib/addons/**/*').pipe(gulp.dest(`${buildDir}/addons`)); | ||
|
|
||
| // Copy stylesheets from src/ to lib/ | ||
| let copyStylesheets = gulp.src('lib/**/*.css').pipe(gulp.dest(buildDir)); | ||
|
|
||
| return merge(bundleStream, copyAddons, copyStylesheets); | ||
| }); | ||
|
|
||
|
|
||
| /** | ||
| * Use `sorcery` to resolve the source map chain and point back to the TypeScript files. | ||
| * (Without this task the source maps produced for the JavaScript bundle points into the | ||
| * compiled JavaScript files in lib/). | ||
| */ | ||
| gulp.task('sorcery', ['browserify'], function () { | ||
| var chain = sorcery.loadSync(`${buildDir}/xterm.js`); | ||
| var map = chain.apply(); | ||
| chain.writeSync(); | ||
| }); | ||
|
|
||
| gulp.task('build', ['sorcery']); | ||
|
|
||
| gulp.task('default', ['build']); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,18 +38,26 @@ | |
| "browserify": "^13.1.0", | ||
| "chai": "3.5.0", | ||
| "docdash": "0.4.0", | ||
| "exorcist": "^0.4.0", | ||
| "express": "4.13.4", | ||
| "express-ws": "2.0.0-rc.1", | ||
| "fs-extra": "^1.0.0", | ||
| "glob": "^7.0.5", | ||
| "gulp": "^3.9.1", | ||
| "gulp-cli": "^1.2.2", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think you install this in the project, only globally.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When used in an package.json script it works. Npm adds |
||
| "gulp-sourcemaps": "1.9.1", | ||
| "gulp-typescript": "^3.1.3", | ||
| "jsdoc": "3.4.3", | ||
| "merge-stream": "^1.0.1", | ||
| "mocha": "2.5.3", | ||
| "nodemon": "1.10.2", | ||
| "pty.js": "0.3.1", | ||
| "sleep": "^3.0.1", | ||
| "sorcery": "^0.10.0", | ||
| "tsify": "^3.0.0", | ||
| "tslint": "^4.0.2", | ||
| "typescript": "^2.0.3" | ||
| "typescript": "^2.0.3", | ||
| "vinyl-buffer": "^1.0.0", | ||
| "vinyl-source-stream": "^1.1.0" | ||
| }, | ||
| "scripts": { | ||
| "prestart": "npm run build", | ||
|
|
@@ -58,7 +66,7 @@ | |
| "lint": "tslint src/**/*.ts", | ||
| "test": "mocha --recursive ./lib", | ||
| "build:docs": "jsdoc -c jsdoc.json", | ||
| "build": "./bin/build", | ||
| "build": "gulp build", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unrelated but can we merge
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's leave this for another PR to keep this as much in context as possible. |
||
| "prepublish": "npm run build" | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sourcemaps don't appear to be working on the demo.
sorcerywas being used because the browserify version needs to resolve dist/xterm.js -> lib/xterm.js > src/xterm.js.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I'll take a look. gulp-sourcemaps was supposed to do this when using
loadMaps.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this could be fixed before this was merged that would be great as I use dev tools pretty heavily for xterm.js dev.