Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.32 KB | None | 0 0
  1. var gulp = require("gulp"),
  2. tsc = require("gulp-typescript"),
  3. concat = require("gulp-concat"),
  4. sourcemaps = require("gulp-sourcemaps"),
  5. mainBowerFiles = require("gulp-main-bower-files"),
  6. filter = require("gulp-filter"),
  7. templateCache = require("gulp-angular-templatecache"),
  8. flatten = require("gulp-flatten");
  9.  
  10. var buildConfig = {
  11. usercode: {
  12. search: "app/**/*.ts",
  13. distFile: "app.js",
  14. distFolder: "dist"
  15. },
  16. userstyle: {
  17. search: "app/**/*.css",
  18. distFile: "app.css",
  19. distFolder: "dist"
  20. },
  21. usertemplates: {
  22. search: "app/**/*.html",
  23. distFile: "app.css",
  24. distFolder: "dist"
  25. },
  26. vendorcode: {
  27. distFile: "vendor.js",
  28. distFolder: "dist"
  29. },
  30. vendorstyle: {
  31. distFile: "vendor.css",
  32. distFolder: "dist"
  33. },
  34. vendorfont: {
  35. distFolder: "fonts"
  36. }
  37. };
  38.  
  39. var tscProject = tsc.createProject("tsconfig.json");
  40.  
  41. gulp.task("default", [
  42. "usercode",
  43. "userstyle",
  44. "usertemplates",
  45. "vendorcode",
  46. "vendorstyle",
  47. "vendorfont"
  48. ], function () {
  49. gulp.watch(["app/**/*.ts"], ["usercode"]);
  50. gulp.watch(["app/**/*.css"], ["userstyle"]);
  51. gulp.watch(["app/**/*.html"], ["usertemplates"]);
  52.  
  53. gulp.watch(["bower_components/**/*.js"], ["vendorcode"]);
  54. gulp.watch(["bower_components/**/*.css"], ["vendorstyle"]);
  55. gulp.watch(["bower_components/**/*.woff2"], ["vendorfont"]);
  56. });
  57.  
  58. gulp.task("build", ["default"]);
  59.  
  60. gulp.task("usercode", function () {
  61. return gulp
  62. .src(buildConfig.usercode.search)
  63. .pipe(tscProject())
  64. .pipe(sourcemaps.init())
  65. .pipe(concat(buildConfig.usercode.distFile))
  66. .pipe(sourcemaps.write("."))
  67. .pipe(gulp.dest(buildConfig.usercode.distFolder));
  68. });
  69.  
  70. gulp.task("userstyle", function () {
  71. return gulp
  72. .src(buildConfig.userstyle.search)
  73. .pipe(concat(buildConfig.userstyle.distFile))
  74. .pipe(gulp.dest(buildConfig.userstyle.distFolder));
  75. });
  76.  
  77. gulp.task("usertemplates", function () {
  78. return gulp
  79. .src(buildConfig.usertemplates.search)
  80. .pipe(templateCache({
  81. module: "templates",
  82. standalone: true,
  83. transformUrl: function (url) {
  84. return url
  85. .replace(/^.*[\/]/, "")
  86. .replace(/.[^/.]+$/, "");
  87. }
  88. }))
  89. .pipe(gulp.dest(buildConfig.usertemplates.distFolder));
  90. });
  91.  
  92. gulp.task("vendorcode", function () {
  93. return gulp
  94. .src("bower.json")
  95. .pipe(mainBowerFiles())
  96. .pipe(sourcemaps.init())
  97. .pipe(filter("**/*.js"))
  98. .pipe(concat(buildConfig.vendorcode.distFile))
  99. .pipe(sourcemaps.write("."))
  100. .pipe(gulp.dest(buildConfig.vendorcode.distFolder));
  101. });
  102.  
  103. gulp.task("vendorstyle", function () {
  104. return gulp
  105. .src("bower.json")
  106. .pipe(mainBowerFiles())
  107. .pipe(filter("**/*.css"))
  108. .pipe(concat(buildConfig.vendorstyle.distFile))
  109. .pipe(gulp.dest(buildConfig.vendorstyle.distFolder));
  110. });
  111.  
  112. gulp.task("vendorfont", function () {
  113. return gulp
  114. .src("bower.json", { base: "./" })
  115. .pipe(mainBowerFiles())
  116. .pipe(filter("**/*.{ttf,woff,eof,svg}"))
  117. .pipe(flatten({
  118. includeParents: -1
  119. }))
  120. .pipe(gulp.dest(buildConfig.vendorfont.distFolder));
  121. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement