Skip to content

Commit

Permalink
🏗️ Adding JS stack for complex admin UI
Browse files Browse the repository at this point in the history
  • Loading branch information
sergei-maertens committed Jan 3, 2020
1 parent ecf2313 commit 1cc202c
Show file tree
Hide file tree
Showing 10 changed files with 3,899 additions and 12 deletions.
7 changes: 7 additions & 0 deletions .babelrc
@@ -0,0 +1,7 @@
{
"comments":false,
"compact":true,
"presets":[
"@babel/preset-env"
]
}
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -16,6 +16,7 @@ __pycache__
src/openzaak/static/fonts
src/openzaak/static/css/screen.css
src/openzaak/static/css/admin/
src/openzaak/static/js/
docs/_build

# Coverage reports
Expand Down
8 changes: 7 additions & 1 deletion build/paths.js
Expand Up @@ -29,5 +29,11 @@ module.exports = {
cssDir: `${staticRoot}css/`,

// Path to the fonts directory
fontsDir: `${staticRoot}fonts/`
fontsDir: `${staticRoot}fonts/`,

jsSrc: `${sourcesRoot}js/**/*.js`,

jsEntryAdmin: `${sourcesRoot}js/admin.js`,

jsDir: `${staticRoot}js/`,
};
7 changes: 5 additions & 2 deletions build/tasks/build.js
@@ -1,5 +1,8 @@
const gulp = require('gulp');
const { sass } = require('./sass');
const { js } = require('./js');

gulp.task('build', sass);
exports.build = sass;
const build = gulp.parallel(sass, js);

gulp.task('build', build);
exports.build = build;
23 changes: 23 additions & 0 deletions build/tasks/js.js
@@ -0,0 +1,23 @@
'use strict';
var gulp = require('gulp');
var webpack = require('webpack-stream');
var paths = require('../paths');
var webpackConfig = require('../../webpack.config.js');


/**
* Js task
* Run using "gulp js"
* Runs webpack to compile javascript
*/
function js() {
return gulp.src(paths.jsEntryAdmin)
.pipe(webpack(webpackConfig))
.on('error', function () {
this.emit('end');
})
.pipe(gulp.dest(webpackConfig.output.path));
};

gulp.task('js', js)
exports.js = js;
26 changes: 23 additions & 3 deletions build/tasks/watch.js
Expand Up @@ -2,7 +2,7 @@
var gulp = require('gulp');
var paths = require('../paths');
const { sass } = require('./sass');

const { js } = require('./js');

/**
* Watch-sass task
Expand All @@ -14,8 +14,28 @@ function watchSASS() {
gulp.watch(paths.sassSrc, sass);
}

/**
* Watch-js task
* Run using "gulp watch-js"
* Runs "js" and "lint" tasks instantly and when any file in paths.jsSrc changes
*/
function watchJS() {
js();
gulp.watch([paths.jsSrc], js);
}

/**
* Watch task
* Run using "gulp watch"
* Runs "watch-js" and "watch-sass" tasks
*/
const watch = gulp.parallel(watchJS, watchSASS);

exports.watchSASS = watchSASS;
gulp.task('watch-sass', watchSASS);

exports.watch = watchSASS;
gulp.task('watch', watchSASS);
exports.watchJS = watchJS;
gulp.task('watch-js', watchJS);

exports.watch = watch;
gulp.task('watch', watch);

0 comments on commit 1cc202c

Please sign in to comment.