Skip to content

Commit 974bfec

Browse files
committed
In sample projects a Gulp was updated to version 4.0.2
1 parent 4e4fb79 commit 974bfec

File tree

9 files changed

+290
-306
lines changed

9 files changed

+290
-306
lines changed

samples/JavaScriptEngineSwitcher.Sample.AspNet4.Mvc4/JavaScriptEngineSwitcher.Sample.AspNet4.Mvc4.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,10 @@
174174
<AspNetCompiler VirtualPath="temp" PhysicalPath="$(WebProjectOutputDir)" />
175175
</Target>
176176
<Target Name="GulpClean" AfterTargets="Clean">
177-
<Exec Command="gulp clean-builded-assets" />
177+
<Exec Command="gulp cleanBuildedAssets" />
178178
</Target>
179179
<Target Name="GulpBuild" AfterTargets="AfterBuild">
180-
<Exec Command="gulp build-assets" />
180+
<Exec Command="gulp buildAssets" />
181181
</Target>
182182
<ProjectExtensions>
183183
<VisualStudio>
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,97 @@
1-
/*global require */
2-
"use strict";
1+
/*global require, exports */
2+
/*jshint esversion: 6 */
33

44
// include plug-ins
5-
var gulp = require('gulp');
6-
var del = require('del');
7-
var sourcemaps = require('gulp-sourcemaps');
8-
var rename = require('gulp-rename');
9-
var concat = require('gulp-concat');
10-
var less = require('gulp-less');
11-
var autoprefixer = require('gulp-autoprefixer');
12-
var cleanCss = require('gulp-clean-css');
13-
var uglify = require('gulp-uglify');
14-
15-
var webRootPath = ".";
16-
var bowerDirPath = "lib";
17-
var styleDirPath = webRootPath + '/styles';
18-
var scriptDirPath = webRootPath + '/scripts';
5+
const { src, dest, series, parallel, watch } = require('gulp');
6+
const del = require('del');
7+
const sourcemaps = require('gulp-sourcemaps');
8+
const rename = require('gulp-rename');
9+
const concat = require('gulp-concat');
10+
const less = require('gulp-less');
11+
const autoprefixer = require('gulp-autoprefixer');
12+
const cleanCss = require('gulp-clean-css');
13+
const uglify = require('gulp-uglify');
14+
15+
const webRootPath = ".";
16+
const bowerDirPath = "lib";
17+
const styleDirPath = webRootPath + '/styles';
18+
const scriptDirPath = webRootPath + '/scripts';
1919

2020
//#region Clean
2121
//#region Clean builded assets
22-
gulp.task('clean-builded-styles', function () {
23-
del.sync([styleDirPath + '/build/*']);
24-
});
22+
function cleanBuildedStyles() {
23+
return del([styleDirPath + '/build/*']);
24+
}
2525

26-
gulp.task('clean-builded-scripts', function () {
27-
del.sync([scriptDirPath + '/build/*']);
28-
});
26+
function cleanBuildedScripts() {
27+
return del([scriptDirPath + '/build/*']);
28+
}
2929

30-
gulp.task('clean-builded-assets', ['clean-builded-styles', 'clean-builded-scripts'], function () { });
30+
const cleanBuildedAssets = parallel(cleanBuildedStyles, cleanBuildedScripts);
3131
//#endregion
3232
//#endregion
3333

3434
//#region Build assets
3535
//#region Build styles
36-
var autoprefixerOptions = {
37-
browsers: ['> 1%', 'last 3 versions', 'Firefox ESR', 'Opera 12.1'],
36+
const autoprefixerOptions = {
37+
overrideBrowserslist: ['> 1%', 'last 3 versions', 'Firefox ESR', 'Opera 12.1'],
3838
cascade: true
3939
};
40-
var cssCleanOptions = { keepSpecialComments: '*' };
41-
var cssRenameOptions = { extname: '.min.css' };
40+
const cssCleanOptions = { specialComments: '*' };
41+
const cssRenameOptions = { extname: '.min.css' };
4242

43-
gulp.task('build-common-styles', function () {
44-
return gulp
45-
.src([styleDirPath + '/app.less'])
43+
function buildCommonStyles() {
44+
return src([styleDirPath + '/app.less'])
4645
.pipe(sourcemaps.init())
4746
.pipe(less({
4847
relativeUrls: true,
4948
rootpath: '/styles/'
5049
}))
5150
.pipe(autoprefixer(autoprefixerOptions))
5251
.pipe(sourcemaps.write('./'))
53-
.pipe(gulp.dest(styleDirPath + '/build'))
52+
.pipe(dest(styleDirPath + '/build'))
5453
.pipe(sourcemaps.init({ loadMaps: true }))
5554
.pipe(concat('common-styles.css'))
5655
.pipe(cleanCss(cssCleanOptions))
5756
.pipe(rename(cssRenameOptions))
5857
.pipe(sourcemaps.write('./'))
59-
.pipe(gulp.dest(styleDirPath + '/build'))
58+
.pipe(dest(styleDirPath + '/build'))
6059
;
61-
});
60+
}
6261

63-
gulp.task('build-styles', ['build-common-styles'], function () { });
62+
const buildStyles = buildCommonStyles;
6463
//#endregion
6564

6665
//#region Build scripts
67-
var jsConcatOptions = { newLine: ';' };
68-
var jsUglifyOptions = {
66+
const jsConcatOptions = { newLine: ';' };
67+
const jsUglifyOptions = {
6968
output: { comments: /^!/ }
7069
};
71-
var jsRenameOptions = { extname: '.min.js' };
70+
const jsRenameOptions = { extname: '.min.js' };
7271

73-
gulp.task('build-modernizr-scripts', function () {
74-
return gulp
75-
.src([bowerDirPath + '/modernizr/modernizr.js'])
72+
function buildModernizrScripts() {
73+
return src([bowerDirPath + '/modernizr/modernizr.js'])
7674
.pipe(sourcemaps.init())
7775
.pipe(uglify(jsUglifyOptions))
7876
.pipe(rename(jsRenameOptions))
7977
.pipe(sourcemaps.write('./'))
80-
.pipe(gulp.dest(scriptDirPath + '/build'))
78+
.pipe(dest(scriptDirPath + '/build'))
8179
;
82-
});
80+
}
8381

84-
gulp.task('build-common-scripts', function () {
85-
return gulp
86-
.src([scriptDirPath + '/common.js'])
82+
function buildCommonScripts() {
83+
return src([scriptDirPath + '/common.js'])
8784
.pipe(sourcemaps.init({ loadMaps: true }))
8885
.pipe(rename({ basename: 'common-scripts' }))
8986
.pipe(uglify(jsUglifyOptions))
9087
.pipe(rename(jsRenameOptions))
9188
.pipe(sourcemaps.write('./'))
92-
.pipe(gulp.dest(scriptDirPath + '/build'))
89+
.pipe(dest(scriptDirPath + '/build'))
9390
;
94-
});
91+
}
9592

96-
gulp.task('build-evaluation-form-scripts', function () {
97-
return gulp
98-
.src([bowerDirPath + '/jquery-validation/dist/jquery.validate.js',
93+
function buildEvaluationFormScripts() {
94+
return src([bowerDirPath + '/jquery-validation/dist/jquery.validate.js',
9995
bowerDirPath + '/jquery-validation-unobtrusive/jquery.validate.unobtrusive.js',
10096
bowerDirPath + '/bootstrap/js/button.js',
10197
scriptDirPath + '/evaluation-form.js'])
@@ -104,32 +100,32 @@ gulp.task('build-evaluation-form-scripts', function () {
104100
.pipe(uglify(jsUglifyOptions))
105101
.pipe(rename(jsRenameOptions))
106102
.pipe(sourcemaps.write('./'))
107-
.pipe(gulp.dest(scriptDirPath + '/build'))
103+
.pipe(dest(scriptDirPath + '/build'))
108104
;
109-
});
105+
}
110106

111-
gulp.task('build-scripts', ['build-modernizr-scripts', 'build-common-scripts',
112-
'build-evaluation-form-scripts'], function () { });
107+
const buildScripts = parallel(buildModernizrScripts, buildCommonScripts, buildEvaluationFormScripts);
113108
//#endregion
114109

115-
gulp.task('build-assets', ['build-styles', 'build-scripts'], function () { });
110+
const buildAssets = parallel(buildStyles, buildScripts);
116111
//#endregion
117112

118113
//#region Watch assets
119-
gulp.task('watch-styles', function () {
120-
return gulp.watch([styleDirPath + '/**/*.{less,css}', '!' + styleDirPath + '/build/**/*.*'],
121-
['build-styles']);
122-
});
114+
function watchStyles() {
115+
return watch([styleDirPath + '/**/*.{less,css}', '!' + styleDirPath + '/build/**/*.*'],
116+
buildStyles);
117+
}
123118

124-
gulp.task('watch-scripts', function () {
125-
return gulp.watch([scriptDirPath + '/**/*.js', '!' + scriptDirPath + '/build/**/*.*'],
126-
['build-scripts']);
127-
});
119+
function watchScripts() {
120+
return watch([scriptDirPath + '/**/*.js', '!' + scriptDirPath + '/build/**/*.*'],
121+
buildScripts);
122+
}
128123

129-
gulp.task('watch-assets', ['watch-styles', 'watch-scripts']);
124+
const watchAssets = parallel(watchStyles, watchScripts);
130125
//#endregion
131126

132-
//Set a default tasks
133-
gulp.task('default', ['clean-builded-assets'], function () {
134-
return gulp.start('build-assets');
135-
});
127+
// Export tasks
128+
exports.cleanBuildedAssets = cleanBuildedAssets;
129+
exports.buildAssets = buildAssets;
130+
exports.watchAssets = watchAssets;
131+
exports.default = series(cleanBuildedAssets, buildAssets);

samples/JavaScriptEngineSwitcher.Sample.AspNet4.Mvc4/package.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
"private": true,
44
"version": "3.2.4",
55
"devDependencies": {
6-
"gulp": "3.9.1",
7-
"del": "3.0.0",
8-
"gulp-sourcemaps": "2.6.1",
9-
"gulp-rename": "1.2.2",
6+
"gulp": "4.0.2",
7+
"del": "5.1.0",
8+
"gulp-sourcemaps": "2.6.5",
9+
"gulp-rename": "2.0.0",
1010
"gulp-concat": "2.6.1",
11-
"gulp-less": "3.3.2",
12-
"gulp-autoprefixer": "4.0.0",
13-
"gulp-clean-css": "2.0.6",
14-
"gulp-uglify": "3.0.0"
11+
"gulp-less": "4.0.1",
12+
"gulp-autoprefixer": "7.0.1",
13+
"gulp-clean-css": "4.2.0",
14+
"gulp-uglify": "3.0.2"
1515
}
1616
}

0 commit comments

Comments
 (0)