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

Homework 5 #5

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
76 changes: 76 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
const gulp = require('gulp');
const concat = require('gulp-concat');
const less = require('gulp-less');
const inject = require('gulp-inject');
const rollup = require('rollup');
const image = require('gulp-image');

const assetsPath = 'src/img/**/*.png';
const stylesPath = './src/styles/**/*.scss';
const jsPath = 'src/**/*.js';
const htmlPath = './src/index.html';
const distPath = './dist/';
const rollupConfig = {
input: 'src/app.js',
plugins: [
// Не используем в rollup, используем это в gulp
// scss(), // will output compiled styles to output.css
// html({ template }),
]
}

const imageOptimizingSettings = {
pngquant: true,
optipng: true,
zopflipng: true,
mozjpeg: true,
gifsicle: true,
svgo: true,
concurrent: 10,
};


gulp.task('rollup', async (done) => {
const bundle = await rollup.rollup(rollupConfig);

bundle.write({
format: 'iife',
file: 'dist/app.js'
});

done();
});


gulp.task('css', () => {
return gulp.src(stylesPath)
.pipe(less())
.pipe(concat('style.css'))
.pipe(gulp.dest(distPath));
});


gulp.task('watch', function (done) {
gulp.watch(stylesPath, gulp.series('css'));
gulp.watch(jsPath, gulp.series('rollup'));
done();
});


gulp.task('img', function () {
return gulp.src(assetsPath)
.pipe(image(imageOptimizingSettings))
.pipe(gulp.dest(`${distPath}/img/`));
});


gulp.task('html', function () {
const target = gulp.src(htmlPath);
const sources = gulp.src(['./dist/**/*.js', './dist/**/*.css'], { read: false });

return target.pipe(inject(sources, { ignorePath: '../dist', relative: true, addPrefix: '.' }))
.pipe(gulp.dest(distPath));
});

gulp.task('default', gulp.series('rollup', 'css', 'img', 'html', 'watch'));
gulp.task('build', gulp.series('rollup', 'css', 'img', 'html'));
9 changes: 9 additions & 0 deletions node_modules/rollup-pluginutils/src/addExtension.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading