You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.1 KiB

4 years ago
  1. import gulp from 'gulp';
  2. import gulpif from 'gulp-if';
  3. import concat from 'gulp-concat';
  4. import webpack from 'webpack';
  5. import gulpWebpack from 'webpack-stream';
  6. import named from 'vinyl-named';
  7. import livereload from 'gulp-livereload';
  8. import plumber from 'gulp-plumber';
  9. import rename from 'gulp-rename';
  10. import uglify from 'gulp-uglify';
  11. import {log,colors} from 'gulp-util';
  12. import args from './util/args';
  13. gulp.task('scripts',()=>{
  14. return gulp.src(['app/js/index.js'])
  15. .pipe(plumber({
  16. errorHandle:function(){
  17. }
  18. }))
  19. .pipe(named())
  20. .pipe(gulpWebpack({
  21. module:{
  22. loaders:[{
  23. test:/\.js$/,
  24. loader:'babel'
  25. }]
  26. }
  27. }),null,(err,stats)=>{
  28. log(`Finished '${colors.cyan('scripts')}'`,stats.toString({
  29. chunks:false
  30. }))
  31. })
  32. .pipe(gulp.dest('server/public/js'))
  33. .pipe(rename({
  34. basename:'cp',
  35. extname:'.min.js'
  36. }))
  37. .pipe(uglify({compress:{properties:false},output:{'quote_keys':true}}))
  38. .pipe(gulp.dest('server/public/js'))
  39. .pipe(gulpif(args.watch,livereload()))
  40. })