Skip to content

Commit

Permalink
update gulp in es6+ styntax
Browse files Browse the repository at this point in the history
  • Loading branch information
xelinel32 committed Jul 29, 2020
1 parent 479f54c commit f97c14b
Show file tree
Hide file tree
Showing 5 changed files with 2,565 additions and 620 deletions.
35 changes: 18 additions & 17 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const sass = require('gulp-sass');
const cleancss = require('gulp-clean-css');
const concat = require('gulp-concat');
const browserSync = require('browser-sync').create();
const uglify = require('gulp-uglify-es').default;
const terser = require('gulp-terser')
const autoprefixer = require('gulp-autoprefixer');
const del = require('del');
const imagemin = require('gulp-image');
Expand All @@ -12,15 +12,17 @@ const sourcemaps = require('gulp-sourcemaps');
const fileinclude = require('gulp-file-include');
const babel = require('gulp-babel');

function browsersync() {
const browsersync = () => {
browserSync.init({
server: { baseDir: 'dest' },
notify: true,
port: 3000
notify: false,
port: 3000,
open: false,
cors: true
});
}

function styles() {
const styles = () => {
return src([
'node_modules/reset-css/reset.css',
'src/scss/style.scss',
Expand All @@ -42,52 +44,51 @@ function styles() {
sourceMap: true,
})
)
.pipe(concat('style.css'))
.pipe(concat('style.min.css'))
.pipe(sourcemaps.write('./'))
.pipe(dest('dest'))
.pipe(browserSync.stream());
}

function scripts() {
const scripts = () => {
return src([
'node_modules/jquery/dist/jquery.js',
'src/script/common.js'
])
.pipe(sourcemaps.init())
.pipe(babel({
presets: ['@babel/env']
}))
.pipe(
uglify({
terser({
toplevel: true,
})
)
.pipe(concat('bundle.js'))
.pipe(concat('bundle.min.js'))
.pipe(sourcemaps.write('./'))
.pipe(dest('dest'))
.pipe(browserSync.stream());
}

function fontPack() {
const fontPack = () => {
return src('src/fonts/*').pipe(dest('dest/fonts'));
}

function imgPack(){
const imgPack = () =>{
return src('src/img/**')
.pipe(newer('dest/img/**'))
.pipe(imagemin())
.pipe(dest('dest/img'))
}

function htmlFileInclude(){
const htmlFileInclude = () => {
return src('src/**.html').pipe(fileinclude({prefix: '@@'})).pipe(dest('dest'))
}

function clear() {
const clear = () => {
return del('dest/**/*');
}

function startwatch() {
const startwatch = () => {
watch('src/scss/**/*.scss', parallel('styles'));
watch('src/script/*.js', parallel('scripts'));
watch('src/img/*', parallel('imgPack'));
Expand All @@ -104,5 +105,5 @@ exports.clear = clear;
exports.fontPack = fontPack;
exports.htmlFileInclude = htmlFileInclude;
exports.imgPack = imgPack;
exports.assets = series(clear, fontPack, imgPack ,htmlFileInclude, styles, scripts);
exports.default = parallel(clear, fontPack, imgPack ,htmlFileInclude, styles, scripts, browsersync, startwatch);
exports.build = series(clear, fontPack, imgPack, htmlFileInclude, styles, scripts);
exports.dev = parallel(clear, fontPack, imgPack, htmlFileInclude, styles, scripts, browsersync, startwatch);
Loading

0 comments on commit f97c14b

Please sign in to comment.