Skip to content

Instantly share code, notes, and snippets.

@X140Yu
Created November 8, 2019 04:07
Show Gist options
  • Save X140Yu/142f60783a7e589fbe367896508699a3 to your computer and use it in GitHub Desktop.
Save X140Yu/142f60783a7e589fbe367896508699a3 to your computer and use it in GitHub Desktop.
gulp + typescript + css + autorebuild
const gulp = require("gulp");
const sourcemaps = require("gulp-sourcemaps");
const ts = require("gulp-typescript");
const tsProject = ts.createProject("tsconfig.json");
const cssInput = "src/**/*.css";
const output = "out";
function typescript(cb) {
tsProject
.src()
.pipe(sourcemaps.init())
.pipe(tsProject())
.on("error", () => {})
.js.pipe(sourcemaps.write())
.pipe(gulp.dest(output));
cb();
}
function css(cb) {
gulp.src(cssInput).pipe(gulp.dest(output));
cb();
}
exports.default = function() {
gulp.series(css, typescript);
};
gulp.task("watch", watch);
function watch(cb) {
gulp.watch(cssInput, { ignoreInitial: false }, css);
gulp.watch(
["src/**/*.ts", "src/**/*.tsx"],
{ ignoreInitial: false },
typescript
);
}
{
"name": "xx",
"displayName": "xxxx",
"description": "xxxx xxxx",
"version": "0.0.1",
"categories": [
"Other"
],
"main": "./out/extension.js",
"scripts": {
"build": "gulp",
"compile": "gulp",
"watch": "gulp watch",
"pretest": "yarn run compile"
},
"devDependencies": {
"@types/node": "^12.6.8",
"@types/react": "^16.7.18",
"@types/react-dom": "^16.0.11",
"electron": "5.0.6",
"gulp": "^4.0.2",
"gulp-sourcemaps": "^2.6.5",
"gulp-typescript": "^5.0.1",
"typescript": "^3.3.1"
},
"license": "MIT"
}
{
"compilerOptions": {
"experimentalDecorators": true,
"module": "commonjs",
"target": "es6",
"outDir": "out",
"moduleResolution": "node",
"jsx": "react",
"lib": [
"es6", "dom"
],
"sourceMap": true,
"rootDir": "src",
"resolveJsonModule": true
},
"exclude": [
"node_modules"
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment