Skip to content

Commit

Permalink
Убирает хэширование из сборки
Browse files Browse the repository at this point in the history
  • Loading branch information
pepelsbey committed May 13, 2024
1 parent f87ecf7 commit b36e6ae
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 330 deletions.
47 changes: 16 additions & 31 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
import babel from 'gulp-babel';
import buffer from 'vinyl-buffer';
import {deleteAsync} from 'del';
import fs from 'fs';
import gulp from 'gulp';
import paths from 'vinyl-paths';
import postcss from 'gulp-postcss';
import replace from 'gulp-replace';
import rev from 'gulp-rev';
import rewrite from 'gulp-rev-rewrite';
import rollup from 'rollup-stream';
import source from 'vinyl-source-stream';
import terser from 'gulp-terser';

// Styles

const postCssPlugins = await Promise.all([
'postcss-import',
'postcss-color-hex-alpha',
Expand Down Expand Up @@ -52,51 +49,38 @@ gulp.task('paths', () => {
.pipe(gulp.dest('dist'));
});

// Cache
// Copy

gulp.task('cache:hash', () => {
gulp.task('copy:binary', () => {
return gulp.src([
'dist/fonts/*.woff2',
'dist/images/**/*.{svg,png,jpg}',
'dist/scripts.js',
'dist/styles/*.css',
'dist/manifest.json',
'dist/images/**/*.{png,jpg}',
], {
base: 'dist',
encoding: false,
})
.pipe(paths(deleteAsync))
.pipe(rev())
.pipe(gulp.dest('dist'))
.pipe(rev.manifest('rev.json'))
.pipe(gulp.dest('dist'));
});

gulp.task('cache:replace', () => {
const manifest = fs.readFileSync('dist/rev.json');

gulp.task('copy:text', () => {
return gulp.src([
'dist/**/*.{html,css}',
'dist/manifest-*.json',
])
.pipe(rewrite({
manifest,
}))
'dist/images/**/*.{svg}',
'dist/scripts.js',
'dist/styles/*.css',
'dist/manifest.json',
], {
base: 'dist',
})
.pipe(gulp.dest('dist'));
});

gulp.task('cache', gulp.series(
'cache:hash',
'cache:replace'
));

// Clean

gulp.task('clean', () => {
return deleteAsync([
'dist/styles/**/*',
'!dist/styles/{styles,print}-*.css',
'!dist/styles/{styles,print}.css',
'dist/scripts/**/*',
'dist/rev.json',
]);
});

Expand All @@ -106,6 +90,7 @@ gulp.task('build', gulp.series(
'styles',
'scripts',
'paths',
'cache',
'copy:binary',
'copy:text',
'clean'
));
Loading

0 comments on commit b36e6ae

Please sign in to comment.