Created
November 8, 2019 04:07
-
-
Save X140Yu/142f60783a7e589fbe367896508699a3 to your computer and use it in GitHub Desktop.
gulp + typescript + css + autorebuild
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"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