Answer the question
In order to leave comments, you need to log in
Why doesn't GULP transfer js files to dist folder?
There is such an assembly for landing. Everything works, but gulp doesn't want to move the compiled file to the dist folder. Checked. I change in src, but changes do not pass to dist. There is a task named script. The problem may be with him. The code was sent, just in case, all. Thanks for the help.
const gulp = require('gulp');
const browserSync = require('browser-sync');
const sass = require('gulp-sass');
const rename = require("gulp-rename");
const autoprefixer = require('gulp-autoprefixer');
const cleanCSS = require('gulp-clean-css');
const imagemin = require('gulp-imagemin');
const htmlmin = require('gulp-htmlmin');
// Static server
gulp.task('server', function() {
browserSync({
server: {
baseDir: "dist"
}
});
gulp.watch("src/*.html").on('change', browserSync.reload);
});
gulp.task('styles', function() {
return gulp.src("src/sass/**/*.+(scss|sass)")
.pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError))
.pipe(rename({suffix: '.min', prefix: ''}))
.pipe(autoprefixer())
.pipe(cleanCSS({compatibility: 'ie8'}))
.pipe(gulp.dest("dist/css"))
.pipe(browserSync.stream());
});
gulp.task('watch', function() {
gulp.watch("src/sass/**/*.+(scss|sass|css)", gulp.parallel('styles'));
gulp.watch("src/*.html").on('change', gulp.parallel('html'));
})
gulp.task('html', function(){
return gulp.src("src/*.html")
.pipe(htmlmin({ collapseWhitespace: true }))
.pipe(gulp.dest("dist/"))
});
gulp.task('scripts', function(){
return gulp.src("src/js/**/*.js")
.pipe(gulp.dest("dist/js"))
});
gulp.task('fonts', function(){
return gulp.src("src/fonts/**/*")
.pipe(gulp.dest("dist/fonts"))
});
gulp.task('images', function(){
return gulp.src("src/images/**/*")
.pipe(imagemin())
.pipe(gulp.dest("dist/images"))
});
gulp.task('mailer', function(){
return gulp.src("src/mailer/**/*")
.pipe(gulp.dest("dist/mailer"))
});
gulp.task('default', gulp.parallel('watch', 'server', 'styles', 'scripts', 'fonts', 'images', 'mailer', 'html'));
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question