Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix css 编译时序问题导致有事无法正确生成css文件的bug #136

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 17 additions & 14 deletions Gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,26 @@ var paths = {
// CSS task
gulp.task('css', function() {

// Convert scss first
gulp.src('app/assets/sass/**/*.scss')
// Cleanup old assets
del(['public/assets/css/styles-*.css'], function (err) {});

// Convert scss first
// Prefix, compress and concat the CSS assets
// Afterwards add the MD5 hash to the filename

return gulp.src('app/assets/sass/**/*.scss')
.pipe(sass())
.pipe(autoprefixer('last 10 version'))
.pipe(gulp.dest('app/assets/css/dist'));

// Cleanup old assets
del(['public/assets/css/styles-*.css'], function (err) {});
.pipe(gulp.dest('app/assets/css/dist'))
.on('end',function() {
gulp.src(paths.frontend.styles)
.pipe(concat('styles.css'))
.pipe(rev())
.pipe(filename({ bundleName: 'frontend.styles' })) // This will create/update the assets.json file
.pipe(minifycss())
.pipe(gulp.dest('public/assets/css'));
});

// Prefix, compress and concat the CSS assets
// Afterwards add the MD5 hash to the filename
return gulp.src(paths.frontend.styles)
.pipe(concat('styles.css'))
.pipe(rev())
.pipe(filename({ bundleName: 'frontend.styles' })) // This will create/update the assets.json file
.pipe(minifycss())
.pipe(gulp.dest('public/assets/css'));
});

// JavaScript task
Expand Down