refactored Dockerfile
This commit is contained in:
parent
8f4a53db64
commit
90f6a07d4a
8 changed files with 68 additions and 33 deletions
|
@ -1,4 +1,4 @@
|
|||
const genmap = require('../build/generate_asset_map');
|
||||
const genmap = require('./generate_asset_map');
|
||||
const isServer = typeof genmap === 'function';
|
||||
let prefix = '';
|
||||
let manifest = {};
|
||||
|
|
29
common/generate_asset_map.js
Normal file
29
common/generate_asset_map.js
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
This code is included by both the server and frontend via
|
||||
common/assets.js
|
||||
|
||||
When included from the server the export will be the function.
|
||||
|
||||
When included from the frontend (via webpack) the export will
|
||||
be an object mapping file names to hashed file names. Example:
|
||||
"send_logo.svg": "send_logo.5fcfdf0e.svg"
|
||||
*/
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
function kv(f) {
|
||||
return `"${f}": require('../assets/${f}')`;
|
||||
}
|
||||
|
||||
module.exports = function() {
|
||||
const files = fs.readdirSync(path.join(__dirname, '..', 'assets'));
|
||||
const code = `module.exports = {
|
||||
${files.map(kv).join(',\n')}
|
||||
};`;
|
||||
return {
|
||||
code,
|
||||
dependencies: files.map(f => require.resolve('../assets/' + f)),
|
||||
cacheable: true
|
||||
};
|
||||
};
|
|
@ -1,3 +1,7 @@
|
|||
# Common Code
|
||||
|
||||
This directory contains code loaded by both the frontend `app` and backend `server`. The code here can be challenging to understand at first because the contexts for the two (three counting the dev server) environments that include them are quite different, but the purpose of these modules are quite simple, to provide mappings from the source assets (`copy-16.png`) to the concrete production assets (`copy-16.db66e0bf.svg`).
|
||||
This directory contains code loaded by both the frontend `app` and backend `server`. The code here can be challenging to understand at first because the contexts for the two (three counting the dev server) environments that include them are quite different, but the purpose of these modules are quite simple, to provide mappings from the source assets (`copy-16.png`) to the concrete production assets (`copy-16.db66e0bf.svg`).
|
||||
|
||||
## Generate Asset Map
|
||||
|
||||
This loader enumerates all the files in `assets/` so that `common/assets.js` can provide mappings from the source filename to the hashed filename used on the site.
|
Loading…
Add table
Add a link
Reference in a new issue