Created
August 12, 2018 14:35
-
-
Save vladimirmyshkovski/95a4ac069252356579dcedfe6483e66d to your computer and use it in GitHub Desktop.
Remove unused css from index.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//////////////////////////////// | |
//Setup// | |
//////////////////////////////// | |
// Plugins | |
var gulp = require('gulp'), | |
pjson = require('./package.json'), | |
uncss = require('postcss-uncss'), | |
comments = require('postcss-discard-comments'), | |
cssnext = require('postcss-cssnext'), | |
assets = require('postcss-assets'), | |
cssnano = require('cssnano'), | |
autoprefixer = require('autoprefixer'), | |
concat = require('gulp-concat'), | |
postcss = require('gulp-postcss'), | |
rename = require('gulp-rename') | |
// Create bundle.min.css file | |
gulp.task('bundleCss', function() { | |
var plugins = [ | |
uncss({ | |
html: 'index.html', | |
report: true, | |
}), | |
comments({removeAll: true}), | |
cssnext, | |
assets, | |
cssnano, | |
autoprefixer({browsers: ['> 1%'], cascade: false}), | |
]; | |
return gulp.src('./css/**/*.css') | |
.pipe(concat('bundle.css')) | |
.pipe(postcss(plugins)) | |
.pipe(rename({ suffix: '.min' })) | |
.pipe(gulp.dest('./css')); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "", | |
"scripts": { | |
"gulp": "gulp" | |
}, | |
"devDependencies": { | |
"autoprefixer": "^8.4.1", | |
"cssnano": "^3.10.0", | |
"gulp": "^4.0.0", | |
"gulp-postcss": "^7.0.1", | |
"gulp-concat": "^2.5.2", | |
"gulp-rename": "^1.2.0", | |
"postcss-assets": "^5.0.0", | |
"postcss-cssnext": "^3.1.0", | |
"postcss-discard-comments": "^2.0.4", | |
"postcss-uncss": "^0.16.1", | |
"uncss": "^0.16.2" | |
}, | |
"dependencies": {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment