diff --git a/bin/browserid b/bin/browserid index 77b89ecdb14a896475fc591c776fe869e6d69d15..6f23273cbcb5e5c86adc231d3831e548b7175c6b 100755 --- a/bin/browserid +++ b/bin/browserid @@ -138,7 +138,7 @@ var static_root = path.join(__dirname, "..", "resources", "static"); app.use(cachify.setup(assets(config.get('supported_languages')), { - prefix: 'v', + prefix: config.get('cachify_prefix'), production: config.get('use_minified_resources'), root: static_root, })); diff --git a/lib/configuration.js b/lib/configuration.js index ab8ca16037197cc166a9e2cf0e62c099792593ca..eca775e276a164affb00a5fa666e676a9b37f779 100644 --- a/lib/configuration.js +++ b/lib/configuration.js @@ -67,6 +67,10 @@ var conf = module.exports = convict({ doc: "The scheme of the public URL. Calculated from the latter.", format: "string", }, + cachify_prefix: { + doc: "The prefix for cachify hashes in URLs", + format: 'string = "v"' + }, use_minified_resources: { doc: "Should the server serve minified resources?", format: 'boolean = true', diff --git a/scripts/compress-worker.js b/scripts/compress-worker.js index 4ffb923334576fe0c511821d5c1c4eeb8bc994e9..4c9616bffe4a048a05e3cbcd4288ef65f60fb2ad 100644 --- a/scripts/compress-worker.js +++ b/scripts/compress-worker.js @@ -1,5 +1,6 @@ const cachify = require('connect-cachify'), +config = require('../lib/configuration.js'), fs = require('fs'), jsp = require("uglify-js").parser, logger = require('../lib/logging.js').logger, @@ -11,6 +12,12 @@ path = require('path'); function compressResource(staticPath, name, files, cb) { var orig_code = ""; var info = undefined; + + // Cachify only used in compress for CSS Images, so no asserts needed + cachify.setup({}, { + prefix: config.get('cachify_prefix'), + root: staticPath + }); function writeFile(final_code) { mkdirp(path.join(staticPath, path.dirname(name)), function (err) { if (err) cb(err); @@ -81,11 +88,6 @@ function compressResource(staticPath, name, files, cb) { isBuildNeeded(); } -var static_root = path.join(__dirname, '..', 'resources/static/'); -logger.info("cachify will look in " + static_root); -// Cachify only used in compress for CSS Images, so no asserts needed -cachify.setup({}, { prefix: 'v', root: static_root }); - function cachify_embedded (css_src) { return css_src.replace(/url\s*\(['"](.*)\s*['"]\s*\)/g, function (str, url) { // This will throw an error if url doesn't exist. This is good as we will @@ -105,4 +107,4 @@ process.on('message', function(m) { info: info }); }); -}); +}); \ No newline at end of file