Implement watching of src files
This commit is contained in:
parent
ddd728bd81
commit
0a42a830e2
|
@ -6,36 +6,75 @@ import babel from 'gulp-babel';
|
|||
import watchify from 'watchify';
|
||||
import runSequence from 'run-sequence';
|
||||
|
||||
import path from 'path';
|
||||
|
||||
const PATHS = {
|
||||
WEBPACK_CONFIG: './webpack.config.js',
|
||||
APP_SRC: 'app/src',
|
||||
APP_DEST: 'app/lib',
|
||||
|
||||
|
||||
|
||||
CLI_SRC: 'src',
|
||||
CLI_DEST: 'lib'
|
||||
};
|
||||
//
|
||||
//APP_ALL: this.APP_SRC + '/**/*',
|
||||
//APP_STATIC_ALL: path.join(this.APP_SRC, 'static') + '/**/*',
|
||||
//APP_STATIC_DEST: path.join(this.APP_DEST, 'static'),
|
||||
//CLI_SRC_JS: this.CLI_SRC + '/**/*.js',
|
||||
|
||||
PATHS.APP_MAIN_JS = path.join(PATHS.APP_SRC, '/main.js'),
|
||||
PATHS.APP_ALL = PATHS.APP_SRC + '/**/*';
|
||||
PATHS.APP_STATIC_ALL = path.join(PATHS.APP_SRC, 'static') + '/**/*';
|
||||
PATHS.APP_STATIC_DEST = path.join(PATHS.APP_DEST, 'static');
|
||||
PATHS.CLI_SRC_JS = PATHS.CLI_SRC + '/**/*.js';
|
||||
|
||||
|
||||
console.log(PATHS);
|
||||
|
||||
gulp.task('default', ['build']);
|
||||
|
||||
gulp.task('build', callback => {
|
||||
runSequence('clean', ['build-cli', 'build-app'], callback);
|
||||
});
|
||||
|
||||
gulp.task('build-app', ['build-static'], function () {
|
||||
return gulp.src('app/src/main.js')
|
||||
.pipe(webpack(require('./webpack.config.js')))
|
||||
.pipe(gulp.dest('app/lib'));
|
||||
gulp.task('build-app', ['build-static'], () => {
|
||||
return gulp.src(PATHS.APP_MAIN_JS)
|
||||
.pipe(webpack(require(PATHS.WEBPACK_CONFIG)))
|
||||
.pipe(gulp.dest(PATHS.APP_DEST));
|
||||
});
|
||||
|
||||
gulp.task('clean', callback => {
|
||||
del('lib').then(() => {
|
||||
del('app/lib').then(() => {
|
||||
del(PATHS.CLI_DEST).then(() => {
|
||||
del(PATHS.APP_DEST).then(() => {
|
||||
callback();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
gulp.task('build-cli', () => {
|
||||
return gulp.src("src/**/*.js")
|
||||
gulp.task('build-cli', done => {
|
||||
return gulp.src(PATHS.CLI_SRC_JS)
|
||||
.pipe(sourcemaps.init())
|
||||
.pipe(babel())
|
||||
.on('error', done)
|
||||
.pipe(sourcemaps.write('.'))
|
||||
.pipe(gulp.dest('lib'));
|
||||
});
|
||||
|
||||
gulp.task('build-static', () => {
|
||||
// copy any html files in source/ to public/
|
||||
return gulp.src('app/src/static/**/*')
|
||||
.pipe(gulp.dest('app/lib/static/'));
|
||||
return gulp.src(PATHS.APP_STATIC_ALL)
|
||||
.pipe(gulp.dest(PATHS.APP_STATIC_DEST));
|
||||
});
|
||||
|
||||
gulp.task('watch', ['build'], () => {
|
||||
var handleError = function (error) {
|
||||
console.error(error);
|
||||
};
|
||||
gulp.watch(PATHS.APP_ALL, ['build-app'])
|
||||
.on('error', handleError);
|
||||
|
||||
gulp.watch(PATHS.CLI_SRC_JS, ['build-cli'])
|
||||
.on('error', handleError);
|
||||
});
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
"build-app": "browserify app/src/main.js --node --ignore-missing --detect-globals false --debug -o app/lib/main.js && cp -r app/src/static app/lib/static",
|
||||
"build-module": "babel src -d lib",
|
||||
"build": "npm run build-app && npm run build-module",
|
||||
"watch": "babel --watch src -d lib",
|
||||
"watch": "while true ; do gulp watch ; done",
|
||||
"prepublish": "npm run build",
|
||||
"package-placeholder": "npm run build && node lib/cli.js http://www.medium.com ~/Desktop --overwrite && open ~/Desktop/Medium-darwin-x64/Medium.app",
|
||||
"start-placeholder": "npm run build && electron app",
|
||||
|
|
Loading…
Reference in New Issue