Skip to content

Commit

Permalink
Simplify build steps with uglifyjs
Browse files Browse the repository at this point in the history
  • Loading branch information
dpilafian committed Oct 3, 2022
1 parent d6809a2 commit 4ed9897
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 18 deletions.
15 changes: 0 additions & 15 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,13 @@
// Gulp configuration and tasks

// Imports
import babel from 'gulp-babel';
import cssNano from 'cssnano';
import gap from 'gulp-append-prepend';
import gulp from 'gulp';
import postCss from 'gulp-postcss';
import rename from 'gulp-rename';
import size from 'gulp-size';

// Setup
const transpileES6 = ['@babel/env', { modules: false }];
const babelMinifyJs = { presets: [transpileES6, 'minify'], comments: false };

// Tasks
const task = {

Expand All @@ -29,17 +24,7 @@ const task = {
.pipe(gulp.dest('build'));
},

minifyJs() {
return gulp.src('src/hamburger-menu.js')
.pipe(babel(babelMinifyJs))
.pipe(rename({ extname: '.min.js' }))
.pipe(gap.appendText('\n'))
.pipe(size({ showFiles: true }))
.pipe(gulp.dest('build'));
},

};

// Gulp
gulp.task('minify-css', task.minifyCss);
gulp.task('minify-js', task.minifyJs);
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"step:02": "jshint . --exclude-path .gitignore",
"step:05": "gulp minify-css",
"step:06": "copy-folder src --ext=.js build",
"step:07": "gulp minify-js",
"step:07": "uglifyjs src/hamburger-menu.js --output build/hamburger-menu.min.js",
"step:08": "add-dist-header build dist --delimiter=☰",
"step:09": "copy-file dist/hamburger-menu.css --folder docs",
"step:10": "copy-file dist/hamburger-menu.js --folder docs",
Expand All @@ -58,8 +58,6 @@
"jquery": "~3.6"
},
"devDependencies": {
"@babel/core": "~7.19",
"@babel/preset-env": "~7.19",
"@fortawesome/fontawesome-free": "~6.2",
"add-dist-header": "~0.3",
"assert-deep-strict-equal": "~1.0",
Expand All @@ -81,6 +79,7 @@
"npm-run-all2": "~6.0",
"postcss": "~8.4",
"rimraf": "~3.0",
"uglify-js": "~3.17",
"w3c-html-validator": "~1.1",
"web-ignition": "~1.5"
}
Expand Down

0 comments on commit 4ed9897

Please sign in to comment.