Skip to content

Commit 7f11145

Browse files
committed
Update gulp
1 parent 6cf2802 commit 7f11145

13 files changed

+3341
-2602
lines changed

css/marx.css

Lines changed: 2 additions & 966 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

css/marx.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

css/marx.min.css.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

css/marx.styl.css

Lines changed: 2 additions & 722 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

css/marx.styl.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

css/marx.styl.min.css.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gulpfile.js

Lines changed: 84 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,90 @@
1-
const
2-
browserSync = require('browser-sync'),
3-
gulp = require('gulp'),
4-
gulpAutoprefixer = require('gulp-autoprefixer'),
5-
gulpCleanCss = require('gulp-clean-css'),
6-
gulpDest = require('gulp-dest'),
7-
gulpPlumber = require('gulp-plumber'),
8-
gulpRename = require('gulp-rename'),
9-
gulpSass = require('gulp-sass'),
10-
gulpSourcemaps = require('gulp-sourcemaps'),
11-
gulpStylus = require('gulp-stylus')
1+
// Load plugins
2+
const browsersync = require('browser-sync').create();
3+
const gulp = require('gulp');
4+
const autoprefixer = require('autoprefixer');
5+
const sass = require('gulp-sass');
6+
const stylus = require('gulp-stylus');
7+
const cssnano = require('cssnano');
8+
const postcss = require('gulp-postcss');
9+
const dest = require('gulp-dest');
10+
const plumber = require('gulp-plumber');
11+
const rename = require('gulp-rename');
12+
const sourcemaps = require('gulp-sourcemaps');
13+
const cleanCss = require('gulp-clean-css');
14+
const merge = require('merge-stream');
1215

13-
gulp.task('browser-sync', function () {
14-
browserSync({
15-
server: {
16-
baseDir: './'
17-
}
18-
})
19-
})
16+
// BrowserSync
17+
function browserSync(done) {
18+
browsersync.init({
19+
server: {
20+
baseDir: './'
21+
},
22+
port: 3000
23+
});
24+
done();
25+
}
2026

21-
gulp.task('bs-reload', function () {
22-
browserSync.reload()
23-
})
27+
// BrowserSync Reload
28+
function browserSyncReload(done) {
29+
browsersync.reload();
30+
done();
31+
}
2432

25-
gulp.task('scss', function () {
26-
gulp.src(['scss/**/*.scss'])
27-
.pipe(gulpPlumber({
28-
errorHandler: function (error) {
29-
console.log(error.message)
30-
this.emit('end')
31-
}}))
32-
.pipe(gulpSourcemaps.init())
33-
.pipe(gulpSass())
34-
.pipe(gulpAutoprefixer())
35-
.pipe(gulp.dest('css/'))
36-
.pipe(gulpRename({suffix: '.min'}))
37-
.pipe(gulpCleanCss({compatibility: 'ie8'}))
38-
.pipe(gulpSourcemaps.write('.'))
39-
.pipe(gulp.dest('css/'))
40-
.pipe(browserSync.reload({stream: true}))
41-
})
33+
// SCSS task
34+
function scss() {
35+
return gulp
36+
.src('./scss/**/[^_]*.scss')
37+
.pipe(plumber())
38+
.pipe(sourcemaps.init())
39+
.pipe(sass())
40+
.pipe(postcss([autoprefixer(), cssnano()]))
41+
.pipe(gulp.dest('css/'))
42+
.pipe(rename({ suffix: '.min' }))
43+
.pipe(cleanCss({ compatibility: 'ie8' }))
44+
.pipe(sourcemaps.write('.'))
45+
.pipe(gulp.dest('css/'))
46+
.pipe(browsersync.stream());
47+
}
4248

43-
gulp.task('styl', function () {
44-
gulp.src(['./node_modules/sanitize.css/sanitize.css'])
45-
.pipe(gulpDest('tmp', {ext: '.styl'}))
46-
.pipe(gulp.dest('./'))
47-
gulp.src(['styl/**/[^_]*.styl'])
48-
.pipe(gulpPlumber({
49-
errorHandler: function (error) {
50-
console.log(error.message)
51-
this.emit('end')
52-
}}))
53-
.pipe(gulpSourcemaps.init())
54-
.pipe(gulpStylus())
55-
.pipe(gulpAutoprefixer())
56-
.pipe(gulpRename({suffix: '.styl'}))
57-
.pipe(gulp.dest('css/'))
58-
.pipe(gulpRename({suffix: '.min'}))
59-
.pipe(gulpCleanCss({compatibility: 'ie8'}))
60-
.pipe(gulpSourcemaps.write('.'))
61-
.pipe(gulp.dest('css/'))
62-
.pipe(browserSync.reload({stream: true}))
63-
})
49+
// SCSS task
50+
function styl() {
51+
var sanitize = gulp
52+
.src(['./node_modules/sanitize.css/sanitize.css'])
53+
.pipe(dest('styl', { ext: '.styl' }))
54+
.pipe(rename({ prefix: '_' }))
55+
.pipe(gulp.dest('./'));
6456

65-
gulp.task('styles', ['scss', 'styl'])
57+
var compile = gulp
58+
.src(['styl/**/[^_]*.styl'])
59+
.pipe(plumber())
60+
.pipe(sourcemaps.init())
61+
.pipe(stylus())
62+
.pipe(postcss([autoprefixer(), cssnano()]))
63+
.pipe(rename({ suffix: '.styl' }))
64+
.pipe(gulp.dest('css/'))
65+
.pipe(rename({ suffix: '.min' }))
66+
.pipe(cleanCss({ compatibility: 'ie8' }))
67+
.pipe(sourcemaps.write('.'))
68+
.pipe(gulp.dest('css/'))
69+
.pipe(browsersync.stream());
6670

67-
gulp.task('default', ['browser-sync'], function () {
68-
gulp.watch('scss/**/*.scss', ['scss'])
69-
gulp.watch('styl/**/*.styl', ['styl'])
70-
gulp.watch('*.html', ['bs-reload'])
71-
})
71+
return merge(sanitize, compile);
72+
}
73+
74+
// Watch files
75+
function watchFiles() {
76+
gulp.watch('./scss/**/*', scss);
77+
gulp.watch('./styl/**/*', styl);
78+
gulp.watch('*.html', browserSyncReload);
79+
}
80+
81+
// define complex tasks
82+
const build = gulp.series(gulp.parallel(scss, styl));
83+
const watch = gulp.parallel(watchFiles, browserSync);
84+
85+
// export tasks
86+
exports.scss = scss;
87+
exports.styl = styl;
88+
exports.build = build;
89+
exports.watch = watch;
90+
exports.default = build;

package.json

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "marx-css",
3-
"version": "3.0.3",
3+
"version": "3.0.4",
44
"description": "The classless CSS reset (perfect for Communists).",
55
"browserslist": [
66
"> 0.5%",
@@ -64,17 +64,20 @@
6464
"homepage": "https://github.com/mblode/marx",
6565
"dependencies": {},
6666
"devDependencies": {
67-
"browser-sync": "^2.24.4",
68-
"browserslist": "^3.2.8",
69-
"gulp": "^3.9.1",
70-
"gulp-autoprefixer": "^5.0.0",
71-
"gulp-clean-css": "^3.9.4",
67+
"autoprefixer": "^9.4.3",
68+
"browser-sync": "^2.26.3",
69+
"browserslist": "^4.3.7",
70+
"cssnano": "^4.1.8",
71+
"gulp": "^4.0.0",
72+
"gulp-clean-css": "^4.0.0",
7273
"gulp-dest": "^0.2.3",
73-
"gulp-plumber": "^1.2.0",
74-
"gulp-rename": "^1.2.3",
75-
"gulp-sass": "^4.0.1",
74+
"gulp-plumber": "^1.2.1",
75+
"gulp-postcss": "^8.0.0",
76+
"gulp-rename": "^1.4.0",
77+
"gulp-sass": "^4.0.2",
7678
"gulp-sourcemaps": "^2.6.4",
7779
"gulp-stylus": "^2.7.0",
78-
"sanitize.css": "^5.0.0"
80+
"merge-stream": "^1.0.1",
81+
"sanitize.css": "^8.0.0"
7982
}
8083
}

scss/_form.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ input[type="checkbox"]:focus:invalid:focus {
134134
}
135135

136136
select {
137-
-webkit-appearance: menulist-button;
138137
border: $border;
139138
vertical-align: sub;
140139
}

styl/_form.styl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ input[type="checkbox"]:focus:invalid:focus
123123
outline-color: $red
124124

125125
select
126-
-webkit-appearance: menulist-button
127126
border: $border
128127
vertical-align: sub
129128

0 commit comments

Comments
 (0)