gpt4 book ai didi

javascript - Gulp 正在恢复我的所有更改?

转载 作者:行者123 更新时间:2023-11-27 23:26:34 25 4
gpt4 key购买 nike

我 fork 了这个存储库:https://github.com/angular-ui/ui-select并在这里进行了更改:https://github.com/zhen-w/ui-select 。问题是,我对 angular-ui/ui-select 的源代码进行了一些更改,但是当我运行命令 gulp 尝试生成我的缩小版本时文件中,我的所有更改似乎都被恢复,并且生成的缩小文件并不包含我想要的新更改。以下是 gulpfile.js 的内容:

var fs = require('fs');
var gulp = require('gulp');
var karma = require('karma').server;
var concat = require('gulp-concat');
var jshint = require('gulp-jshint');
var header = require('gulp-header');
var footer = require('gulp-footer');
var rename = require('gulp-rename');
var es = require('event-stream');
var del = require('del');
var uglify = require('gulp-uglify');
var minifyHtml = require('gulp-minify-html');
var minifyCSS = require('gulp-minify-css');
var templateCache = require('gulp-angular-templatecache');
var gutil = require('gulp-util');
var plumber = require('gulp-plumber');//To prevent pipe breaking caused by errors at 'watch'

var config = {
pkg : JSON.parse(fs.readFileSync('./package.json')),
banner:
'/*!\n' +
' * <%= pkg.name %>\n' +
' * <%= pkg.homepage %>\n' +
' * Version: <%= pkg.version %> - <%= timestamp %>\n' +
' * License: <%= pkg.license %>\n' +
' */\n\n\n'
};

gulp.task('default', ['build','test']);
gulp.task('build', ['scripts', 'styles']);
gulp.task('test', ['build', 'karma']);

gulp.task('watch', ['build','karma-watch'], function() {
gulp.watch(['src/**/*.{js,html}'], ['build']);
});

gulp.task('clean', function(cb) {
del(['dist'], cb);
});

gulp.task('scripts', ['clean'], function() {

var buildTemplates = function () {
return gulp.src('src/**/*.html')
.pipe(minifyHtml({
empty: true,
spare: true,
quotes: true
}))
.pipe(templateCache({module: 'ui.select'}));
};

var buildLib = function(){
return gulp.src(['src/common.js','src/*.js'])
.pipe(plumber({
errorHandler: handleError
}))
.pipe(concat('select_without_templates.js'))
.pipe(header('(function () { \n"use strict";\n'))
.pipe(footer('\n}());'))
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'))
.pipe(jshint.reporter('fail'));
};

return es.merge(buildLib(), buildTemplates())
.pipe(plumber({
errorHandler: handleError
}))
.pipe(concat('select.js'))
.pipe(header(config.banner, {
timestamp: (new Date()).toISOString(), pkg: config.pkg
}))
.pipe(gulp.dest('dist'))
.pipe(uglify({preserveComments: 'some'}))
.pipe(rename({ext:'.min.js'}))
.pipe(gulp.dest('dist'));

});

gulp.task('styles', ['clean'], function() {

return gulp.src('src/common.css')
.pipe(header(config.banner, {
timestamp: (new Date()).toISOString(), pkg: config.pkg
}))
.pipe(rename('select.css'))
.pipe(gulp.dest('dist'))
.pipe(minifyCSS())
.pipe(rename({ext:'.min.css'}))
.pipe(gulp.dest('dist'));

});

gulp.task('karma', ['build'], function() {
karma.start({configFile : __dirname +'/karma.conf.js', singleRun: true});
});

gulp.task('karma-watch', ['build'], function() {
karma.start({configFile : __dirname +'/karma.conf.js', singleRun: false});
});

var handleError = function (err) {
console.log(err.toString());
this.emit('end');
};

我不明白为什么我的更改会被还原,因为这是我自己的 fork 存储库。任何帮助,将不胜感激。谢谢!

最佳答案

dist 目录中的所有内容都是由 gulp 创建的 - 不仅仅是缩小的文件。如果要进行更改,请编辑 src 目录下的相应文件。

关于javascript - Gulp 正在恢复我的所有更改?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34917549/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com