本文整理汇总了TypeScript中gulp-typescript.createProject函数的典型用法代码示例。如果您正苦于以下问题:TypeScript createProject函数的具体用法?TypeScript createProject怎么用?TypeScript createProject使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了createProject函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: error
gulp.task("test:compile", () => {
let n_errors = 0
function error(err: {message: string}) {
gutil.log(err.message)
n_errors++
}
const project = ts.createProject("./test/tsconfig.json")
const compiler = project
.src()
.pipe(project(ts.reporter.nullReporter()).on("error", error))
const result = compiler
.js
.pipe(gulp.dest(join("./build", "test")))
result.on("finish", function() {
if (argv.emitError && n_errors > 0) {
gutil.log(`There were ${chalk.red("" + n_errors)} TypeScript errors.`)
process.exit(1)
}
})
return result
})
示例2: function
gulp.task('compile-project', function () {
var opts = {
basedir: config.paths.app,
debug: true
};
var streamFinished = function () {
gutil.log('End stream');
};
var entry = config.paths.app + '/main.ts';
var fileName = path.basename(entry, path.extname(entry)) + ".js";
var project = ts.createProject('tsconfig_m.json', {
outFile: fileName
});
var tsResult = project.src()
.pipe(project())
.pipe(wrap({ src: 'template.txt' }))
.pipe(gulp.dest(config.paths.pub))
.pipe(rename({ suffix: '.debug' }))
.pipe(gulp.dest(config.paths.pub))
.pipe(uglify())
.pipe(rename(fileName))
.pipe(gulp.dest(config.paths.pub))
.on('end', streamFinished);
});
示例3: require
gulp.task('karma:build', () => {
const typescript = require('gulp-typescript');
const sourcemaps = require('gulp-sourcemaps');
const tplinline = require('gulp-inline-ng2-template');
const errors = require('../utils/errors');
const paths = require('../config/paths');
const config = {
typescript: require('../config/typescript'),
tplinline: require('../config/tplinline')
};
const tsProject = typescript.createProject(paths.typescript.appConfig, config.typescript);
return gulp
.src([
paths.typings,
paths.sources.scripts,
'!' + paths.sources.bootstrap,
'!' + paths.scripts.tests.e2e
])
.pipe(sourcemaps.init())
.pipe(tplinline(config.tplinline))
.pipe(typescript(tsProject))
.js
.pipe(sourcemaps.write())
.on('error', errors)
.pipe(gulp.dest(paths.output.app));
});
示例4: compile
function compile(isRelease: boolean) {
var tsProject = ts.createProject({
removeComments: true, // Do not emit comments to output.
//noImplicitAny: false, // Warn on expressions and declarations with an implied 'any' type.
//noLib: false, // Don't include the default lib (with definitions for - Array, Date etc)
//noEmitOnError: false, // Do not emit outputs if any type checking errors were reported.
//target: "ES3", // Specify ECMAScript target version: 'ES3' (default), 'ES5' or 'ES6'.
//module: "", // Specify module code generation: 'commonjs' or 'amd'
//sourceRoot: "", // Specifies the location where debugger should locate TypeScript files instead of source locations.
declarationFiles: false, // Generates corresponding .d.ts files.
noExternalResolve: false, // Do not resolve files that are not in the input. Explanation below.
sortOutput: true, // Sort output files. Usefull if you want to concatenate files (see below).
});
var tsResult = gulp.src(srcGlob)
.pipe(ts(tsProject, { referencedFrom: ['Application.ts'] }));
return tsResult.js
.pipe(concat('app.js'))
//.pipe(ngAnnotate())
//.pipe(gulpIf(isRelease, uglify()))
//.pipe(uglify())
.pipe(gulp.dest('Chokaigi2015/html/js'));
}
示例5: error
gulp.task("scripts:ts", () => {
let n_errors = 0
function error(err: {message: string}) {
gutil.log(err.message)
n_errors++
}
const project = ts.createProject(join(paths.src_dir.coffee, "tsconfig.json"))
const compiler = project
.src()
.pipe(sourcemaps.init())
.pipe(project(ts.reporter.nullReporter()).on("error", error))
const result = merge([
compiler.js
.pipe(sourcemaps.write("."))
.pipe(gulp.dest(paths.build_dir.tree)),
compiler.dts
.pipe(gulp.dest(paths.build_dir.types)),
])
result.on("finish", function() {
if (argv.emitError && n_errors > 0) {
gutil.log(`There were ${chalk.red("" + n_errors)} TypeScript errors.`)
process.exit(1)
}
})
return result
})
示例6: build
function build(path: string[]): Promise<any> {
// TODO: remove this if it every works in watch mode without needing to re-create.
let project = gulpTs.createProject('tsconfig.json', {
typescript: require('typescript'),
rootDir: 'modules'
});
let output = gulp.src(path)
.pipe(gulpTs(project));
// Using a promise instead of merging streams since end
// event on streams seems not to be propagated when merged.
return new Promise((resolve) => {
var doneCount = 0;
output.js
.pipe(rename(buildUtils.stripSrcFromPath))
.pipe(gulp.dest('dist'))
.on('end', maybeDone),
output.dts
.pipe(rename(buildUtils.stripSrcFromPath))
.pipe(gulp.dest('dist'))
.on('end', maybeDone)
function maybeDone() {
doneCount++;
if (doneCount == 2) resolve();
}
})
}
示例7:
g.task('ts', () => {
const tsProject = ts.createProject('tsconfig.json')
g.src('src/**/*.ts')
.pipe(sourcemaps.init())
.pipe(tsProject())
.pipe(sourcemaps.write('.'))
.pipe(g.dest('build'))
})
示例8: require
const compile = (name: string) => {
const project = ts.createProject(join(BASE_DIR, name, "tsconfig.json"), {
typescript: require('typescript')
})
return project.src()
.pipe(project(reporter).on('error', (err: {message: string}) => gutil.log(err.message)))
.pipe(gulp.dest(join(BASE_DIR, name)))
}
示例9: compileBundles
// -------------------------------------------------------------------------
// Packaging and Publishing tasks
// -------------------------------------------------------------------------
/**
* Compiles and compiles bundles.
*/
@MergedTask()
compileBundles() {
const amdTsProject = ts.createProject("tsconfig.json", {
module: "amd",
outFile: packageName + ".amd.js",
typescript: require("typescript")
});
const systemTsProject = ts.createProject("tsconfig.json", {
module: "system",
outFile: packageName + ".system.js",
typescript: require("typescript")
});
const amdPureTsProject = ts.createProject("tsconfig.json", {
module: "amd",
outFile: packageName + ".pure.amd.js",
noEmitHelpers: true,
noImplicitUseStrict: true,
typescript: require("typescript")
});
const systemPureTsProject = ts.createProject("tsconfig.json", {
module: "system",
outFile: packageName + ".pure.system.js",
noEmitHelpers: true,
noImplicitUseStrict: true,
typescript: require("typescript")
});
return [
gulp.src("build/bundle/**/*.ts")
.pipe(amdTsProject()).js
.pipe(gulp.dest("build/package")),
gulp.src("build/bundle/**/*.ts")
.pipe(systemTsProject()).js
.pipe(gulp.dest("build/package")),
gulp.src("build/bundle/**/*.ts")
.pipe(amdPureTsProject()).js
.pipe(gulp.dest("build/package")),
gulp.src("build/bundle/**/*.ts")
.pipe(systemPureTsProject()).js
.pipe(gulp.dest("build/package"))
];
}
示例10: function
gulp.task('build:server', function () {
var tsProject = tsc.createProject('server/tsconfig.json');
var tsResult = gulp.src('server/src/**/*.ts')
.pipe(sourcemaps.init())
.pipe(tsc(tsProject))
return tsResult.js
.pipe(sourcemaps.write())
.pipe(gulp.dest('dist/server'))
});