custom: fix import leak

merge-requests/1073/head
Alex Gleason 3 years ago
parent afb7827f40
commit 8d64bf2697
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7

@ -0,0 +1,11 @@
/**
* Functions for dealing with custom build configuration.
*/
/** Require a custom JSON file if it exists */
export const custom = (filename, fallback = {}) => {
const context = require.context('custom', false, /\.json$/);
const path = `./${filename}.json`;
return context.keys().includes(path) ? context(path) : fallback;
};

@ -4,19 +4,12 @@ import { createSelector } from 'reselect';
import gte from 'semver/functions/gte';
import lt from 'semver/functions/lt';
// FIXME: We have to use a dynamic import to trick Webpack into treating it as
// optional, but this causes custom locales to become part of the main chunk.
const importCustom = path => {
try {
return require(`custom/${path}.json`);
} catch(e) {
return {};
}
};
import { custom } from 'soapbox/custom';
// Import custom overrides, if exists
const overrides = importCustom('features');
const overrides = custom('features');
// Truthy array convenience function
const any = arr => arr.some(Boolean);
// For uglification

Loading…
Cancel
Save