Commit f3d2e836 authored by Nick Stenning's avatar Nick Stenning

Tweaks to the frontend build in the Dockerfile

A couple of related improvements to how we build the Dockerfile:

1. Don't invalidate the Python dependencies layer just because
   `package.json`, `gulpfile.js` or `scripts/` changed.
2. Use a prebuilt node-sass binary. The prebuilt binaries supplied by
   the node-sass project aren't compatible with Alpine Linux (which uses
   musl-libc rather than glibc).
3. Make some small tweaks to the gulpfile so we can build just the
   assets needed for the web application (i.e. skipping the extension).
parent 3a234b6a
......@@ -12,7 +12,6 @@ var gulpIf = require('gulp-if');
var gulpUtil = require('gulp-util');
var sass = require('gulp-sass');
var postcss = require('gulp-postcss');
var runSequence = require('run-sequence');
var sourcemaps = require('gulp-sourcemaps');
var manifest = require('./scripts/gulp/manifest');
......@@ -62,10 +61,6 @@ var appBundles = [{
name: 'app',
transforms: ['coffee'],
entry: './h/static/scripts/app.coffee',
},{
// Browser extension background script
name: 'extension',
entry: './h/browser/chrome/lib/extension',
},{
// The Annotator library which provides annotation controls on
// the page and sets up the sidebar
......@@ -102,6 +97,23 @@ gulp.task('watch-app-js', ['build-vendor-js'], function () {
});
});
var extensionBundleConfig = {
name: 'extension',
entry: './h/browser/chrome/lib/extension',
path: SCRIPT_DIR,
external: vendorModules,
minify: IS_PRODUCTION_BUILD,
noParse: vendorBundles.noParseModules,
};
gulp.task('build-extension-js', ['build-vendor-js'], function () {
return createBundle(extensionBundleConfig);
});
gulp.task('watch-extension-js', ['build-vendor-js'], function () {
return createBundle(extensionBundleConfig, {watch: true});
});
var styleFiles = [
// H
'./h/static/styles/admin.scss',
......@@ -174,8 +186,6 @@ function generateManifest() {
});
}
gulp.task('generate-manifest', generateManifest);
gulp.task('watch-manifest', function () {
gulp.watch(MANIFEST_SOURCE_FILES, batch(function (events, done) {
endOfStream(generateManifest(), function () {
......@@ -184,13 +194,25 @@ gulp.task('watch-manifest', function () {
}));
});
gulp.task('build', function (callback) {
runSequence(['build-app-js', 'build-css',
'build-fonts', 'build-images'],
'generate-manifest',
callback);
});
gulp.task('watch', ['watch-app-js', 'watch-css',
'watch-fonts', 'watch-images',
'watch-manifest']);
gulp.task('build-app',
['build-app-js',
'build-css',
'build-fonts',
'build-images'],
generateManifest);
gulp.task('build',
['build-app-js',
'build-extension-js',
'build-css',
'build-fonts',
'build-images'],
generateManifest);
gulp.task('watch',
['watch-app-js',
'watch-extension-js',
'watch-css',
'watch-fonts',
'watch-images',
'watch-manifest']);
......@@ -55,7 +55,6 @@
"raf": "^3.1.0",
"raven-js": "^2.0.2",
"retry": "^0.8.0",
"run-sequence": "^1.1.5",
"scroll-into-view": "^1.3.1",
"showdown": "^1.2.1",
"through2": "^2.0.1",
......@@ -88,9 +87,6 @@
"engines": {
"node": "0.10.x"
},
"scripts": {
"build-assets": "gulp build"
},
"repository": {
"type": "git",
"url": "https://github.com/hypothesis/h.git"
......
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