Skip to content

Commit

Permalink
ci: Build static assets for production
Browse files Browse the repository at this point in the history
  • Loading branch information
tdgroot committed Jan 26, 2023
1 parent b1672b9 commit 7a66e17
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ pub
.vscode
*.css.map
deployment-report.json
package-lock.json
build/
node_modules/
14 changes: 14 additions & 0 deletions deploy.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@
run('ln -s docs/_build/html pub');
});

# Install NPM packages from package.json
task('npm:prepare', static function () {
run('npm install');
});

# Build static assets for production using gulp
task('assets:compile', static function () {
run('ls -l ./docs/_static/css');
run('whoami');
run('npx gulp buildProd');
});

# HMV configuration for when this is running in a docker
task('deploy:hmv_docker', static function () use (&$DOCKER_HOST, &$DOCKER_WEBROOT) {
if (test('[ -f /etc/hypernode/is_docker ]')) {
Expand All @@ -68,6 +80,8 @@
});

$configuration = new Configuration();
$configuration->addBuildTask('npm:prepare');
$configuration->addBuildTask('assets:compile');
$configuration->addBuildTask('python:venv:create');
$configuration->addBuildTask('python:venv:requirements');
$configuration->addBuildTask('python:build_documentation');
Expand Down
29 changes: 29 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const { series } = require('gulp');
const cleanCSS = require('gulp-clean-css');
const gulp = require('gulp');
const sass = require('gulp-sass')(require('sass'));
const sourcemaps = require('gulp-sourcemaps');
const terser = require('gulp-terser');

function cssCompile() {
return gulp.src('./docs/_static/scss/*.scss')
.pipe(sourcemaps.init())
.pipe(sass.sync().on('error', sass.logError))
.pipe(sourcemaps.write())
.pipe(gulp.dest('./docs/_static/css'));
}

function cssMinify() {
return gulp.src('./docs/_static/css/*.css')
.pipe(cleanCSS())
.pipe(gulp.dest('./docs/_static/css'));
}

function jsMinify() {
return gulp.src('./docs/_static/js/*.js')
.pipe(terser())
.pipe(gulp.dest('./docs/_static/js'));
}

exports.default = series(cssCompile);
exports.buildProd = series(cssCompile, cssMinify, jsMinify);
12 changes: 12 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"devDependencies": {
"clean-css": "^5.3.2",
"gulp": "^4.0.2",
"gulp-clean-css": "^4.3.0",
"gulp-sass": "^5.1.0",
"gulp-sourcemaps": "^3.0.0",
"gulp-terser": "^2.1.0",
"sass": "^1.57.1",
"terser": "^5.16.1"
}
}

0 comments on commit 7a66e17

Please sign in to comment.