本文整理汇总了TypeScript中gulp-replace类的典型用法代码示例。如果您正苦于以下问题:TypeScript gulp-replace类的具体用法?TypeScript gulp-replace怎么用?TypeScript gulp-replace使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了gulp-replace类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: Promise
return new Promise((resolve, reject) => {
source.pipe(greplace('{{__version}}', version))
.pipe(greplace('{{__apphost}}', apphost))
.pipe(gulp.dest(`./.tmp/`))
.on('end', () => {
resolve()
})
})
示例2: require
gulp.task('build:client:script', () => {
const client = require('./built/client/meta.json');
return gulp.src(['./src/client/app/boot.js', './src/client/app/safe.js'])
.pipe(replace('VERSION', JSON.stringify(client.version)))
.pipe(replace('API', JSON.stringify(config.api_url)))
.pipe(replace('ENV', JSON.stringify(env)))
.pipe(replace('LANGS', JSON.stringify(Object.keys(locales))))
.pipe(isProduction ? uglify({
toplevel: true
} as any) : gutil.noop())
.pipe(gulp.dest('./built/client/assets/'));
});
示例3: buildBundle
export default async function (env: string, target: string, callback?: Function) {
await buildBundle(env, target)
const config = require(`../../config/${env}.json`)
const cdnPrefix = `https://dn-st.teambition.net/${config.cdnNames[target]}`
const revall = new RevAll({
prefix: cdnPrefix,
dontGlobal: [/\/favicon\.ico$/],
dontRenameFile: [/\.html$/],
dontUpdateReference: [/\.html$/],
dontSearchFile: [/lib.js/, /images/]
})
const stream = merge2([
gulp.src([
`www/index.html`,
`www/fonts/**`,
`www/images/**`
]),
gulp.src([
`www/js/**`
])
.pipe(stripDebug())
.pipe(uglify())
.pipe(greplace('/weixin/dev/signature', '/weixin/signature'))
.pipe(greplace('/weixin/dev/tpl/message', '/weixin/tpl/message'))
.pipe(greplace('http://"+window.location.host+"/images/teambition.png', '/images/teambition.png'))
.pipe(greplace('/weixin/dev/', '/weixin/')),
gulp.src([
`www/css/**`
]).pipe(cssNano({rebase: false})),
])
.pipe(revall.revision())
.pipe(gulp.dest(`dist`), callback)
return new Promise((resolve, reject) => {
stream.on('end', async function() {
resolve()
})
})
}
示例4: getPackageNamesConfig
task('generate-ts-config', () => {
const { theme }: PackageNamesConfig = getPackageNamesConfig(process.argv);
let stream = src('tsconfig.publish.json');
for (const packageName of NEBULAR_PACKAGES) {
stream = stream.pipe(replace(`@nebular/${dasherize(packageName)}`, theme))
}
return stream
.pipe(rename('tsconfig-custom.publish.json'))
.pipe(dest('.'));
});
示例5: getReplacements
task('change-prefix', ['copy-build-dir-and-rename', 'generate-ts-config', 'patch-rollup-config'], () => {
const replacements: StringReplacement[] = getReplacements(getPackageNamesConfig(process.argv));
let stream = src(`${BUILD_DIR}/**/*`);
for (const { from, to } of replacements) {
stream = stream.pipe(replace(from, to));
}
return stream
.pipe(dest(BUILD_DIR))
.on('end', replaceScssWithCss);
});
示例6: src
task('patch-rollup-config', () => {
let stream = src(ROLLUP_CONFIG_PATH);
const config: PackageNamesConfig = getPackageNamesConfig(process.argv);
const { unscopedPrefix, unprefixed: unprefixedPackageNames } = config;
const replacements: StringReplacement[] = getReplacements(config);
// Add replacers for `nb.[package-name]`
for (const [ nbPackageName, customPackageName ] of Object.entries(unprefixedPackageNames)) {
replacements.push({
from: `nb.${dasherize(nbPackageName)}`,
to: `${unscopedPrefix}.${customPackageName}`,
});
}
for (const { from, to } of replacements) {
stream = stream.pipe(replace(from, to));
}
return stream.pipe(dest(ROLLUP_CONFIG_DIR));
});
示例7: function
gulp.task('templates', function(){
gulp.src(['file.txt'])
.pipe(replace("test", "foo"))
.pipe(replace(/foo(.{3})/g, '$1foo'))
.pipe(gulp.dest('build/file.txt'));
});
示例8:
keys.forEach((key) => {
if (typeof envConfig[key] === 'string') {
source.pipe(greplace(defaultConfig[key], envConfig[key]))
}
})