aboutsummaryrefslogtreecommitdiffstats
path: root/packages/kovan-faucets/gulpfile.js
diff options
context:
space:
mode:
authorBrandon Millman <brandon.millman@gmail.com>2017-11-21 05:12:15 +0800
committerBrandon Millman <brandon.millman@gmail.com>2017-12-13 07:45:22 +0800
commitbbb768c5cfa8bf713670608f859debae42b42898 (patch)
tree40ae6f11995fa44a1ee58092a8308faac63abec4 /packages/kovan-faucets/gulpfile.js
parent5678196706a63d27fc5b00b5224c8213510e76f0 (diff)
downloaddexon-sol-tools-bbb768c5cfa8bf713670608f859debae42b42898.tar
dexon-sol-tools-bbb768c5cfa8bf713670608f859debae42b42898.tar.gz
dexon-sol-tools-bbb768c5cfa8bf713670608f859debae42b42898.tar.bz2
dexon-sol-tools-bbb768c5cfa8bf713670608f859debae42b42898.tar.lz
dexon-sol-tools-bbb768c5cfa8bf713670608f859debae42b42898.tar.xz
dexon-sol-tools-bbb768c5cfa8bf713670608f859debae42b42898.tar.zst
dexon-sol-tools-bbb768c5cfa8bf713670608f859debae42b42898.zip
Add kovan faucet project into the mono repo
Diffstat (limited to 'packages/kovan-faucets/gulpfile.js')
-rw-r--r--packages/kovan-faucets/gulpfile.js98
1 files changed, 98 insertions, 0 deletions
diff --git a/packages/kovan-faucets/gulpfile.js b/packages/kovan-faucets/gulpfile.js
new file mode 100644
index 000000000..3e80e656e
--- /dev/null
+++ b/packages/kovan-faucets/gulpfile.js
@@ -0,0 +1,98 @@
+const gulp = require('gulp');
+const nodemon = require('nodemon');
+const path = require('path');
+const webpack = require('webpack');
+const fs = require('fs');
+
+const nodeModules = {};
+fs.readdirSync('node_modules')
+ .filter(function(x) {
+ return ['.bin'].indexOf(x) === -1;
+ })
+ .forEach(function(mod) {
+ nodeModules[mod] = 'commonjs ' + mod;
+ });
+
+const config = {
+ target: 'node',
+ entry: ['./src/ts/server.ts'],
+ output: {
+ path: path.join(__dirname, '/bin'),
+ filename: 'server.js',
+ },
+ devtool: 'source-map',
+ resolve: {
+ modules: [
+ path.join(__dirname, '/src/ts'),
+ 'node_modules',
+ ],
+ extensions: ['.ts', '.tsx', '.js', '.jsx', '.json'],
+ alias: {
+ ts: path.join(__dirname, '/src/ts'),
+ contract_artifacts: path.join(__dirname, '/src/contract_artifacts'),
+ },
+ },
+ module: {
+ rules: [
+ {
+ test: /\.js$/,
+ loader: 'source-map-loader',
+ },
+ {
+ test: /\.tsx?$/,
+ loader: 'awesome-typescript-loader',
+ },
+ ],
+ },
+ plugins: [
+ new webpack.BannerPlugin({
+ banner: 'require("source-map-support").install();',
+ raw: true,
+ entryOnly: false,
+ }),
+ ],
+ externals: nodeModules,
+ watchOptions: {
+ ignored: /bin|node_modules|transpiled/
+ },
+};
+
+gulp.task('build', function(done) {
+ webpack(config).run(onBuild(done));
+});
+
+gulp.task('watch', function() {
+ webpack(config).watch(100, function(err, stats) {
+ onBuild()(err, stats);
+ nodemon.restart();
+ });
+});
+
+gulp.task('run', ['watch'], function() {
+ nodemon({
+ execMap: {
+ js: 'node',
+ },
+ script: path.join(__dirname, 'bin/server'),
+ ignore: ['*'],
+ watch: ['foo/'],
+ ext: 'noop',
+ }).on('restart', function() {
+ console.log('Restarted!');
+ });
+});
+
+function onBuild(done) {
+ return function(err, stats) {
+ if(err) {
+ console.log('Error', err);
+ }
+ else {
+ console.log(stats.toString());
+ }
+
+ if(done) {
+ done();
+ }
+ }
+}