Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var gulp = require("gulp"),
- tsc = require("gulp-typescript"),
- concat = require("gulp-concat"),
- sourcemaps = require("gulp-sourcemaps"),
- mainBowerFiles = require("gulp-main-bower-files"),
- filter = require("gulp-filter"),
- templateCache = require("gulp-angular-templatecache"),
- flatten = require("gulp-flatten");
- var buildConfig = {
- usercode: {
- search: "app/**/*.ts",
- distFile: "app.js",
- distFolder: "dist"
- },
- userstyle: {
- search: "app/**/*.css",
- distFile: "app.css",
- distFolder: "dist"
- },
- usertemplates: {
- search: "app/**/*.html",
- distFile: "app.css",
- distFolder: "dist"
- },
- vendorcode: {
- distFile: "vendor.js",
- distFolder: "dist"
- },
- vendorstyle: {
- distFile: "vendor.css",
- distFolder: "dist"
- },
- vendorfont: {
- distFolder: "fonts"
- }
- };
- var tscProject = tsc.createProject("tsconfig.json");
- gulp.task("default", [
- "usercode",
- "userstyle",
- "usertemplates",
- "vendorcode",
- "vendorstyle",
- "vendorfont"
- ], function () {
- gulp.watch(["app/**/*.ts"], ["usercode"]);
- gulp.watch(["app/**/*.css"], ["userstyle"]);
- gulp.watch(["app/**/*.html"], ["usertemplates"]);
- gulp.watch(["bower_components/**/*.js"], ["vendorcode"]);
- gulp.watch(["bower_components/**/*.css"], ["vendorstyle"]);
- gulp.watch(["bower_components/**/*.woff2"], ["vendorfont"]);
- });
- gulp.task("build", ["default"]);
- gulp.task("usercode", function () {
- return gulp
- .src(buildConfig.usercode.search)
- .pipe(tscProject())
- .pipe(sourcemaps.init())
- .pipe(concat(buildConfig.usercode.distFile))
- .pipe(sourcemaps.write("."))
- .pipe(gulp.dest(buildConfig.usercode.distFolder));
- });
- gulp.task("userstyle", function () {
- return gulp
- .src(buildConfig.userstyle.search)
- .pipe(concat(buildConfig.userstyle.distFile))
- .pipe(gulp.dest(buildConfig.userstyle.distFolder));
- });
- gulp.task("usertemplates", function () {
- return gulp
- .src(buildConfig.usertemplates.search)
- .pipe(templateCache({
- module: "templates",
- standalone: true,
- transformUrl: function (url) {
- return url
- .replace(/^.*[\/]/, "")
- .replace(/.[^/.]+$/, "");
- }
- }))
- .pipe(gulp.dest(buildConfig.usertemplates.distFolder));
- });
- gulp.task("vendorcode", function () {
- return gulp
- .src("bower.json")
- .pipe(mainBowerFiles())
- .pipe(sourcemaps.init())
- .pipe(filter("**/*.js"))
- .pipe(concat(buildConfig.vendorcode.distFile))
- .pipe(sourcemaps.write("."))
- .pipe(gulp.dest(buildConfig.vendorcode.distFolder));
- });
- gulp.task("vendorstyle", function () {
- return gulp
- .src("bower.json")
- .pipe(mainBowerFiles())
- .pipe(filter("**/*.css"))
- .pipe(concat(buildConfig.vendorstyle.distFile))
- .pipe(gulp.dest(buildConfig.vendorstyle.distFolder));
- });
- gulp.task("vendorfont", function () {
- return gulp
- .src("bower.json", { base: "./" })
- .pipe(mainBowerFiles())
- .pipe(filter("**/*.{ttf,woff,eof,svg}"))
- .pipe(flatten({
- includeParents: -1
- }))
- .pipe(gulp.dest(buildConfig.vendorfont.distFolder));
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement