Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Build static assets for production #101

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/
15 changes: 15 additions & 0 deletions deploy.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,19 @@
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('chmod -R 755 docs/_static');
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 +81,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"
}
}