Unverified Commit f6d91be4 authored by Ken Hawkins's avatar Ken Hawkins Committed by GitHub
Browse files

Feature: vf2.0 pages (#16)

* Setup draft impact page

* Make local browser dev available by gulp task

* Support image files

* Update draft impact page

* Layout refinements

* Add draft industry page

* Impact page layout updates

* Don't inline data url

* Move test pages to /sample
parent 45b27a2b
Pipeline #31086 passed with stages
in 2 minutes and 11 seconds
......@@ -41,3 +41,6 @@ dist
# Jekyll
_site
# Junk
.DS_Store
......@@ -46,19 +46,27 @@ We use [Gitlab's CI service* to build the assets](https://gitlab.ebi.ac.uk/ebiwd
* This Gitlab instance is only accessible from the EBI network.
### Versioning
We are using a semantic versioning style of releases.
We use semantic versioning style of releases.
| Major release | Minor release | Note |
| ------------- | ------------- | ---- |
| (Branch) | (Tag) | |
| master | .0 | Initial major release |
| master | .0 | Initial release |
| master | .1 | Tagged minor release |
### Test changes
More radical changes should be done on a feature branch.
## Developing content
Serve non-optimised `./src/` files from your dev environment:
- `gulp dev` (alias for `gulp browser-sync`)
## Optimising the pages
If you wish to test the optimisation process on your local machine, here's what you need to do:
NOTE: Only developers would have the need do this.
......@@ -70,9 +78,7 @@ NOTE: Only developers would have the need do this.
- Run the default gulp script: `gulp`
3. If you're using Docker:
- `docker run -it --rm -v $PWD:/workspace -w /workspace simonvanderveldt/node-bower-gulp:6 bash -c 'npm install --quiet && gulp'`
4. Serve files from your dev environment:
- Option A: Jekyll `jekyll serve --port 88`
- Option B: BrowserSync `browser-sync start --server --files "src/*.*" --index src/index.html`
### What the optimisations get you
......
......@@ -6,6 +6,7 @@ const critical = require('critical').stream;
const minifyInline = require('gulp-minify-inline');
const through = require('through2');
const del = require('del');
const browserSync = require('browser-sync').create();
// Ensure dist folder is reset
gulp.task('purge', function(cb){
......@@ -25,6 +26,16 @@ gulp.task('inline-images', function(cb){
});
});
// Handle any jpg, svg, png assets
gulp.task('file-assets', function(cb){
return gulp.src(['src/*.{png,gif,jpg,svg}','src/**/*.{png,gif,jpg,svg}'])
.pipe(gulp.dest('dist/'))
.on('error', function(err) {
gutil.log(gutil.colors.red(err.message));
process.exit(1);
});
});
// Generate & Inline Critical-path CSS
// https://github.com/addyosmani/critical
// https://github.com/addyosmani/critical-path-css-demo
......@@ -55,7 +66,7 @@ gulp.task('critical', function (cb) {
// Minify any inline css/js
// https://www.npmjs.com/package/gulp-minify-inline
let optionsminify = {
const optionsminify = {
// js: {
// output: {
// comments: true
......@@ -81,15 +92,15 @@ gulp.task('minify-inline', function(cb) {
// Write a partial apache config
// https://github.com/ebiwd/EBI-Corporatesite/issues/1
let pipeFunction = () => {
const pipeFunction = () => {
  return through.obj((file, enc, cb) => {
    console.log(file.path);
    return cb(null, file);
  });
};
gulp.task('apache-config', function(cb) {
let fileName = 'dist/.htaccess';
let endOfLine = '\r\n';
const fileName = 'dist/.htaccess';
const endOfLine = '\r\n';
require('fs').writeFileSync(fileName, '# Static page mappings built with gulp');
require('fs').appendFileSync(fileName, endOfLine); // new line
require('fs').appendFileSync(fileName, 'AddOutputFilterByType DEFLATE text/html');
......@@ -97,7 +108,7 @@ gulp.task('apache-config', function(cb) {
require('fs').appendFileSync(fileName, 'RewriteCond %{QUERY_STRING} !(^|&)q=');
return gulp.src(['dist/*.html','dist/**/*.html'])
.pipe(through.obj(function (file, enc, cb) {
let localFilePath = file.path.split('/dist/')[1];
const localFilePath = file.path.split('/dist/')[1];
gutil.log(gutil.colors.green('Mapping: ',localFilePath));
require('fs').appendFileSync(fileName, endOfLine); // new line
require('fs').appendFileSync(fileName, 'RewriteRule ^/'+localFilePath.split('index.htm')[0]+'?$ /staticpages/'+localFilePath+' [L]');
......@@ -113,12 +124,29 @@ gulp.task('apache-config', function(cb) {
);
});
// Development server
gulp.task('browser-sync', function() {
browserSync.init({
server: {
baseDir: "./src"
}
});
gulp.watch('**/*.{png,gif,jpg,svg,html}').on('change', browserSync.reload);
// gulp.watch('**/*.{png,gif,jpg,svg}' , ['file-assets']);
});
// Build it all
gulp.task('default', gulp.series(
'purge','inline-images','critical','minify-inline','apache-config'
'purge','file-assets','inline-images','critical','minify-inline','apache-config'
));
// Alias for default
gulp.task('dev', gulp.series(
gulp.task('build', gulp.series(
'default'
));
// Alias for default
gulp.task('dev', gulp.series(
'browser-sync'
));
This diff is collapsed.
......@@ -17,10 +17,9 @@
"url": "https://github.com/ebiwd/EBI-Corporatesite/issues"
},
"homepage": "https://github.com/ebiwd/EBI-Corporatesite#readme",
"dependencies": {
"critical": "^1.3.4"
},
"devDependencies": {
"browser-sync": "^2.26.7",
"critical": "^1.3.4",
"del": "^5.0.0",
"gulp": "^4.0.2",
"gulp-inline-images": "^1.2.6",
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment