'use strict';

require('shelljs/global');
const gulp = require('gulp');
const babel = require('gulp-babel');
const ts = require('gulp-typescript');
const tslint = require('gulp-tslint');

const project = ts.createProject('tsconfig.json');

gulp.task('build', [
	'build:js',
	'build:ts',
	'build:copy'
]);

gulp.task('buildall', [
	'build',
	'build:client'
]);

gulp.task('build:js', () =>
	gulp.src(['./src/**/*.js', '!./src/web/**/*.js'])
		.pipe(babel({
			presets: ['es2015', 'stage-3']
		}))
		.pipe(gulp.dest('./built/'))
);

gulp.task('build:ts', () =>
	project
		.src()
		.pipe(project())
		.pipe(babel({
			presets: ['es2015', 'stage-3']
		}))
		.pipe(gulp.dest('./built/'))
);

gulp.task('build:client', ['build:ts', 'build:js'], () => {
	const config = require('./built/config').default;

	cd('./src/web');
	exec('npm install && $(npm bin)/bower install --allow-root');
	exec(`npm run build -- --url=${config.url} --recaptcha-siteKey=${config.recaptcha.siteKey}`);
	cd('../../');

	return gulp.src('./src/web/built/**/*')
		.pipe(gulp.dest('./built/web/'));
});

gulp.task('build:copy', () => {
	return gulp.src([
		'./src/**/resources/**/*'
	]).pipe(gulp.dest('./built/'));
});

gulp.task('test', ['lint', 'buildall']);

gulp.task('lint', () =>
	gulp.src('./src/**/*.ts')
		.pipe(tslint({
			formatter: "verbose"
		}))
		.pipe(tslint.report())
);

@@ -181,16 +181,125 @@
 int');%0A%0A
+const env = process.env.NODE_ENV;%0Aconst isProduction = env === 'production';%0Aconst isDebug = !isProduction;%0A%0A
 const pr
@@ -905,26 +905,63 @@
 t;%0A%0A%09cd(
-'./src/web
+isProduction ? './src/web' : './../misskey-web/
 ');%0A%09exe
@@ -1122,16 +1122,17 @@
 %09cd(
-'../../'
+__dirname
 );%0A%0A
@@ -1148,23 +1148,70 @@
 ulp.src(
-'./src/
+isProduction ? './src/web/built/**/*' : './../misskey-
 web/buil

Fix https://github.com/syuilo/misskey-web/issues/80