本文整理汇总了TypeScript中gulp-sourcemaps.init函数的典型用法代码示例。如果您正苦于以下问题:TypeScript init函数的具体用法?TypeScript init怎么用?TypeScript init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了init函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
const streams = entriesAndSources.map(({ entry, name, sources }: IEntry): any =>
settings.gulp
.src(sources)
.pipe(sourcemaps.init())
.pipe(webpack({
entry,
externals,
output: {
library: name,
libraryTarget: "amd"
}
}))
.pipe(rename(`${name}.js`))
.pipe(uglify())
.pipe(sourcemaps.write("."))
.pipe(settings.gulp.dest(Constants.folders.dist)));
示例2: buildTypeScript
function buildTypeScript() {
typescriptCompiler = ts.createProject('tsconfig.json', {
"typescript": require('typescript')
});
let dts = gulp.src(project.transpiler.dtsSource);
let src = gulp.src(project.transpiler.source)
.pipe(changedInPlace({firstPass: true}));
return eventStream.merge(dts, src)
.pipe(plumber({ errorHandler: notify.onError('Error: <%= error.message %>') }))
.pipe(sourcemaps.init())
.pipe(typescriptCompiler())
.pipe(build.bundle());
}
示例3: getCompilerSettings
gulp.task(generateLocalizedDiagnosticMessagesJs, /*help*/ false, [], () => {
const settings: tsc.Settings = getCompilerSettings({
target: "es5",
declaration: false,
removeComments: true,
noResolve: false,
stripInternal: false,
types: ["node", "xml2js"]
}, /*useBuiltCompiler*/ false);
return gulp.src(generateLocalizedDiagnosticMessagesTs)
.pipe(newer(generateLocalizedDiagnosticMessagesJs))
.pipe(sourcemaps.init())
.pipe(tsc(settings))
.pipe(sourcemaps.write("."))
.pipe(gulp.dest(scriptsDirectory));
});
示例4: getCompilerSettings
gulp.task(processDiagnosticMessagesJs, false, [], () => {
const settings: tsc.Settings = getCompilerSettings({
target: "es5",
declaration: false,
removeComments: true,
noResolve: false,
stripInternal: false,
outFile: processDiagnosticMessagesJs
}, /*useBuiltCompiler*/ false);
return gulp.src(processDiagnosticMessagesTs)
.pipe(newer(processDiagnosticMessagesJs))
.pipe(sourcemaps.init())
.pipe(tsc(settings))
.pipe(sourcemaps.write("."))
.pipe(gulp.dest("."));
});
示例5:
gulp.task("build.css", ["build.css.dev"], () => {
return gulp.src(["src/themes/*.scss"])
.pipe(plumber())
.pipe(sourcemaps.init())
.pipe(sass({
includePaths: ["src/**/*.scss"],
}))
.pipe(autoprefixer({
browsers: ["last 2 versions"],
cascade: false
}))
.pipe(cleanCSS())
.pipe(sourcemaps.write())
.pipe(plumber.stop())
.pipe(gulp.dest("./dist"));
});
示例6: error
gulp.task("scripts:tsjs", ["scripts:coffee", "scripts:js", "scripts:ts"], () => {
function error(err: {message: string}) {
const raw = stripAnsi(err.message)
const result = raw.match(/(.*)(\(\d+,\d+\): error TS(\d+):.*)/)
if (result != null) {
const [, file, rest, code] = result
const real = path.join('src', 'coffee', ...file.split(path.sep).slice(3))
if (fs.existsSync(real)) {
gutil.log(`${gutil.colors.red(real)}${rest}`)
return
}
// XXX: can't enable "6133", because CS generates faulty code for closures
if (["2307", "2688", "6053"].indexOf(code) != -1) {
gutil.log(err.message)
return
}
}
if (!argv.ts)
return
if (typeof argv.ts === "string") {
const keywords = argv.ts.split(",")
for (let keyword of keywords) {
let must = true
if (keyword[0] == "^") {
keyword = keyword.slice(1)
must = false
}
const found = err.message.indexOf(keyword) != -1
if (!((found && must) || (!found && !must)))
return
}
}
gutil.log(err.message)
}
const tree_ts = paths.build_dir.tree_ts
return gulp.src(`${tree_ts}/**/*.ts`)
.pipe(sourcemaps.init())
.pipe(ts(tsconfig.compilerOptions, ts.reporter.nullReporter()).on('error', error))
.pipe(sourcemaps.write("."))
.pipe(gulp.dest(paths.build_dir.tree_js))
})
示例7: getCompilerSettings
gulp.task("browserify", "Runs browserify on run.js to produce a file suitable for running tests in the browser", [servicesFile], (done) => {
const testProject = tsc.createProject("src/harness/tsconfig.json", getCompilerSettings({ outFile: "built/local/bundle.js" }, /*useBuiltCompiler*/ true));
return testProject.src()
.pipe(newer("built/local/bundle.js"))
.pipe(sourcemaps.init())
.pipe(tsc(testProject))
.pipe(through2.obj((file, enc, next) => {
browserify(intoStream(file.contents))
.bundle((err, res) => {
// assumes file.contents is a Buffer
file.contents = res;
next(undefined, file);
});
}))
.pipe(sourcemaps.write(".", { includeContent: false, sourceRoot: "../../" }))
.pipe(gulp.dest("."));
});
示例8: ts
@Task('ts')
ts() {
return gulp.src(['app/ts/**/*.ts', '!app/ts/**/*.spec.ts'])
.pipe(sourcemaps.init())
.pipe(ts({
noImplicitAny: false,
target: 'ES5',
module: 'commonjs',
removeComments: true
}))
.pipe(concat('main.js'))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./app/js'))
.pipe(browserSync.reload({
stream: true
}));
}
示例9: build
function build(
buildDir: string,
minifyScripts: boolean,
bundleScripts: boolean,
embedSourceMap: boolean,
separateBuildDir: boolean
): Promise<void> {
return sourceMapUtil.waitForStreamEnd(
gulp.src(path.join(buildDir, separateBuildDir ? '../src/*.js' : '*.js'))
.pipe(sourcemaps.init())
.pipe(minifyScripts ? uglify({ mangle: false, compress: { sequences: false } }) : nop())
.pipe(bundleScripts ? concat('bundle.js') : rename((path) => { path.basename += '.min'; }))
.pipe(mapSources((srcPath) => separateBuildDir ? '../src/' + srcPath : srcPath))
.pipe(sourcemaps.write(embedSourceMap ? undefined : '.', { includeContent: false }))
.pipe(gulp.dest(buildDir)));
}