Roll dice (eg Asphodice) and show outcomes https://rpg.bertieb.org/dice-roller/
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

124 lines
3.0 KiB

  1. var version = require("./package.json").version
  2. let gulp = require("gulp");
  3. let browserSync = require("browser-sync").create();
  4. let sass = require("gulp-sass");
  5. var ts = require("gulp-typescript");
  6. var tsProject = ts.createProject("tsconfig.json");
  7. var browserify = require("browserify");
  8. var source = require("vinyl-source-stream");
  9. var tsify = require("tsify");
  10. var watchify = require("watchify");
  11. var fancy_log = require("fancy-log");
  12. const zip = require("gulp-zip")
  13. var paths = {
  14. pages: ["src/html/*.html"],
  15. css: ["src/css/*.css"],
  16. ts: ["src/ts/frontend.ts"],
  17. };
  18. var browserifyOpts = {
  19. basedir: ".",
  20. debug: true,
  21. entries: paths.ts,
  22. cache: {},
  23. packageCache: {},
  24. }
  25. var browserifyBuildOpts = browserify(browserifyOpts);
  26. var browserifyWatchOpts = browserify(Object.assign({},browserifyOpts));
  27. function browserifyBuild() {
  28. return browserifyBuildOpts
  29. .plugin("tsify")
  30. .bundle()
  31. .pipe(source("bundle.js"))
  32. .pipe(gulp.dest("dist"));
  33. };
  34. var watchedBrowserify = watchify(browserifyWatchOpts).plugin("tsify");
  35. function watchedBundle() {
  36. return watchedBrowserify
  37. .bundle()
  38. .on("error", fancy_log)
  39. .pipe(source("bundle.js"))
  40. .pipe(gulp.dest("dist"));
  41. }
  42. /**
  43. * Uses version in package.json to create zip
  44. */
  45. function versionedZip() {
  46. return gulp.src("./dist/**")
  47. .pipe(zip(`${version}.zip`))
  48. .pipe(gulp.dest("."));
  49. }
  50. // Non-injecting SASS
  51. gulp.task('sass-noninject', function() {
  52. return gulp.src("src/scss/*.scss")
  53. .pipe(sass())
  54. .pipe(gulp.dest("dist/"))
  55. });
  56. // Compile sass into CSS & auto-inject into browsers
  57. gulp.task('sass', function() {
  58. return gulp.src("src/scss/*.scss")
  59. .pipe(sass())
  60. .pipe(gulp.dest("dist/"))
  61. .pipe(browserSync.stream());
  62. });
  63. gulp.task("copy-html", function () {
  64. return gulp.src(paths.pages).pipe(gulp.dest("dist"));
  65. });
  66. /*
  67. * NB: removed pending "do we actually need it" check
  68. *
  69. gulp.task("copy-css", function () {
  70. return gulp.src(paths.css).pipe(gulp.dest("dist/css"));
  71. });
  72. */
  73. gulp.task("compile-ts", function () {
  74. return tsProject.src().pipe(tsProject()).js.pipe(gulp.dest("dist"));
  75. });
  76. // Build without watching
  77. gulp.task("build", gulp.series(
  78. gulp.parallel("copy-html", "sass-noninject"),
  79. browserifyBuild
  80. ));
  81. gulp.task("build-hs", gulp.parallel("copy-html", "sass"));
  82. // Zip dist/ - eg for building Docker images where node isn't installed
  83. gulp.task("zip", gulp.series("build", versionedZip));
  84. // Static Server + compile ts + watch scss/html/css files
  85. gulp.task('serve', gulp.series("build-hs", watchedBundle, function() {
  86. browserSync.init({
  87. server: "./dist/"
  88. });
  89. gulp.watch("src/scss/*.scss", gulp.series('sass'));
  90. //gulp.watch("src/css/*.css").on('change', gulp.series("copy-css"));
  91. gulp.watch("src/html/*.html").on('change', gulp.series("copy-html"));
  92. gulp.watch("dist/*.html").on('change', browserSync.reload);
  93. gulp.watch("dist/*.js").on('change', browserSync.reload);
  94. watchedBrowserify.on("update", watchedBundle);
  95. watchedBrowserify.on("log", fancy_log);
  96. }));
  97. gulp.task('default', gulp.series('serve'));