Skip to content

Commit

Permalink
Add sourcemap support and update gulpfile
Browse files Browse the repository at this point in the history
  • Loading branch information
ayush-goyal committed May 17, 2021
1 parent 289489c commit 6947bb3
Show file tree
Hide file tree
Showing 6 changed files with 224 additions and 276 deletions.
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
.DS_Store
.env
node_modules/
client/node_modules/
server/node_modules/
node_modules
server/src/config/config.json
server/build/
server/src/api/graphql.types.ts
server/dist/
server/src/api/graphql.types.ts

yarn-error.log
41 changes: 14 additions & 27 deletions server/gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,24 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const gulp = require("gulp");
const gutil = require("gulp-util");
const ts = require("gulp-typescript");
const nodemon = require("nodemon");
const path = require("path");
const gulpCopy = require("gulp-copy");
const sourcemaps = require('gulp-sourcemaps');
const del = require('del');

const tsProject = ts.createProject("./tsconfig.json");

gulp.task("watch", () => {
gulp.watch("src/**/*", gulp.series("build:server", "build:static"));
});
// Clean dist folder
gulp.task('clean', () => del('dist'));

gulp.task("build:static", () => gulp.src(["./src/config/*", "./package.json", "./src/api/api.graphql"])
.pipe(gulpCopy("build", { "prefix": 1 })));
// Copy files
gulp.task("copy", () => gulp.src(["./src/config/*", "./src/api/api.graphql"])
.pipe(gulpCopy("dist", { "prefix": 1 })));

gulp.task("build:server", () => tsProject.src()
.pipe(tsProject())
.pipe(gulp.dest("build/")));
// Build ts
gulp.task("build", () => tsProject.src()
.pipe(sourcemaps.init())
.pipe(tsProject())
.pipe(sourcemaps.write(".", { includeContent: false, sourceRoot: '../src' }))
.pipe(gulp.dest("dist")));

gulp.task("build", gulp.series("build:server", "build:static"));

gulp.task("serve", gulp.series("build:server", "build:static", () => {
nodemon({
script: path.join(__dirname, "build/app.js"),
watch: ["build/"],
ignore: ["build/public", "./node_modules"],
env: {
"NODE_ENV": "dev",
},
}).on("start", () => {
gutil.log(gutil.colors.blue("Server started!"));
});
}));

gulp.task("default", gulp.parallel("serve", "watch"));
gulp.task("default", gulp.series("clean", "build", "copy"));
17 changes: 8 additions & 9 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@
"description": "",
"main": "app.js",
"scripts": {
"prestart": "yarn generate && yarn migrate:deploy",
"start": "gulp",
"start-migrate": "yarn migrate:deploy && yarn serve",
"dev": "yarn generate && gulp",
"start": "node dist/app.js",
"start-migrate": "yarn migrate:deploy && yarn start",
"dev": "yarn generate && nodemon --watch 'src/**/*' --exec 'ts-node' src/app.ts",
"migrate:dev": "prisma migrate dev",
"migrate:deploy": "prisma migrate deploy",
"serve": "node ./build/app.js",
"build": "gulp build",
"test": "echo \"Error: no test specified\" && exit 1",
"build": "gulp",
"postinstall": "yarn generate",
"generate": "prisma format && prisma generate && graphql-codegen",
"lint": "eslint src/ --fix; prettier src/ --write"
Expand All @@ -29,6 +26,7 @@
"connect-pg-simple": "^6.2.1",
"cookie-parser": "^1.4.5",
"cookie-signature": "^1.1.0",
"del": "^6.0.0",
"express": "^4.17.1",
"express-graphql": "^0.12.0",
"express-session": "^1.17.1",
Expand All @@ -38,17 +36,17 @@
"graphql-tools": "^7.0.4",
"gulp": "^4.0.2",
"gulp-copy": "^4.0.1",
"gulp-sourcemaps": "^3.0.0",
"gulp-typescript": "^5.0.1",
"gulp-util": "^3.0.8",
"isomorphic-fetch": "^3.0.0",
"moment": "^2.29.1",
"morgan": "^1.10.0",
"nodemon": "^2.0.7",
"passport": "^0.4.1",
"passport-oauth2": "^1.5.0",
"path": "^0.12.7",
"pg": "^8.5.1",
"serve-static": "^1.14.1",
"source-map-support": "^0.5.19",
"subscriptions-transport-ws": "^0.9.18",
"ts-node": "^9.1.1",
"typescript": "^4.2.4"
Expand Down Expand Up @@ -76,6 +74,7 @@
"@types/pg": "^7.14.11",
"@types/ws": "^7.4.1",
"eslint": "^7.24.0",
"nodemon": "^2.0.7",
"prettier": "^2.2.1",
"prisma": "^2.21.2"
},
Expand Down
1 change: 1 addition & 0 deletions server/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import * as path from "path";
import * as cookieSignature from "cookie-signature";
import * as chalk from "chalk";
import "source-map-support/register";

import express from "express";
import serveStatic from "serve-static";
Expand Down
2 changes: 1 addition & 1 deletion server/src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ export const config = new Config();
//
export const PORT = config.server.port;
export const VERSION_NUMBER = JSON.parse(
fs.readFileSync(path.resolve(__dirname, "./package.json"), "utf8")
fs.readFileSync(path.resolve(__dirname, "../package.json"), "utf8")
).version;
export const COOKIE_OPTIONS = {
path: "/",
Expand Down
Loading

0 comments on commit 6947bb3

Please sign in to comment.