Files
old-spike/gulpfile.babel.js

76 lines
2.2 KiB
JavaScript
Raw Normal View History

2016-02-22 14:36:07 -06:00
import gulp from 'gulp';
import yargs from 'yargs';
import webpack from 'webpack';
import gutil from 'gulp-util';
import DB from './server/config/database';
import {PowerDataSeed, HouseSeed} from './server/lib/tasks/seed_data';
import rtCompile from './server/lib/tasks/react_template_compile';
gulp.task('generate_power_csv', function(done){
DB.sync().then(()=>{
PowerDataSeed.generateCsv(yargs.argv, done);
});
});
gulp.task('save_power_csv', function(done){
DB.sync().then(()=>{
PowerDataSeed.saveCsv(yargs.argv, done);
});
});
gulp.task('save_house_csv', function(done){
DB.sync().then(()=>{
HouseSeed.saveCsv(yargs.argv, done);
});
});
gulp.task('compile_react_templates', function() {
gulp.src('./client/dashboard/**/*.rt')
2016-02-22 20:02:45 -06:00
.pipe(rtCompile({
modules: 'es6',
targetVersion: '0.14.0',
suffix: '.rt'
}))
2016-02-22 14:36:07 -06:00
.pipe(gulp.dest('./client/dashboard'));
});
2016-02-22 20:02:45 -06:00
// right now, build only available for design.
2016-02-22 14:36:07 -06:00
gulp.task('build', function(done) {
2016-02-23 00:52:24 -06:00
var config, env,
gulpCopy = require('gulp-copy');
2016-02-22 14:36:07 -06:00
2016-02-22 20:02:45 -06:00
if (yargs.argv.design){
process.env.NODE_ENV = process.env.NODE_ENV || 'design';
2016-02-22 14:36:07 -06:00
} else {
throw new gutil.PluginError("webpack", "Must include '--production' or '--design' option.");
}
2016-02-23 00:52:24 -06:00
config = require(`${__dirname}/client/config/${process.env.NODE_ENV}/webpack.js`);
2016-02-22 14:36:07 -06:00
// run webpack
webpack(config, function(err, stats) {
if(err) throw new gutil.PluginError("webpack", err);
gutil.log("[webpack]", stats.toString({
// output options
}));
2016-02-23 00:52:24 -06:00
if (yargs.argv.design){
gulp.src([
`client/app.scss`
]).pipe(gulpCopy(`client/build/design/dashboard`, {prefix: 1}));
gulp.src([
`client/dashboard/layout/layout.rt`,
`client/dashboard/layout/layout.scss`,
]).pipe(gulpCopy(`client/build/design/dashboard/layout`, {prefix: 3}));
gulp.src([
`client/dashboard/energy/energy.rt`,
`client/dashboard/energy/energy.scss`,
]).pipe(gulpCopy(`client/build/design/dashboard/energy`, {prefix: 3}));
gulp.src([
`client/dashboard/power/power.rt`,
`client/dashboard/power/power.scss`,
]).pipe(gulpCopy(`client/build/design/dashboard/power`, {prefix: 3}));
}
2016-02-22 14:36:07 -06:00
done();
});
});