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.

43 lines
1.1 KiB

4 years ago
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. query: {compact: false}
  26. }]
  27. }
  28. }),null,(err,stats)=>{
  29. log(`Finished '${colors.cyan('scripts')}'`,stats.toString({
  30. chunks:false
  31. }))
  32. })
  33. .pipe(gulp.dest('server/public/js'))
  34. .pipe(rename({
  35. basename:'cp',
  36. extname:'.min.js'
  37. }))
  38. .pipe(uglify({compress:{properties:false},output:{'quote_keys':true}}))
  39. .pipe(gulp.dest('server/public/js'))
  40. .pipe(gulpif(args.watch,livereload()))
  41. })