[dev] Fix build without internet connection (#3230)
This commit is contained in:
parent
f42c013efa
commit
6218fbfd56
@ -25,6 +25,7 @@ const {
|
|||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
|
||||||
const STATOSCOPE_REFERENCE_URL = 'https://tga.dev/build-stats.json';
|
const STATOSCOPE_REFERENCE_URL = 'https://tga.dev/build-stats.json';
|
||||||
|
let isReferenceFetched = false;
|
||||||
const DEFAULT_APP_TITLE = `Telegram${APP_ENV !== 'production' ? ' Beta' : ''}`;
|
const DEFAULT_APP_TITLE = `Telegram${APP_ENV !== 'production' ? ' Beta' : ''}`;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@ -147,8 +148,14 @@ module.exports = (_env, { mode = 'production' }) => {
|
|||||||
...(APP_ENV === 'staging' ? [{
|
...(APP_ENV === 'staging' ? [{
|
||||||
apply: (compiler) => {
|
apply: (compiler) => {
|
||||||
compiler.hooks.compile.tap('Before Compilation', async () => {
|
compiler.hooks.compile.tap('Before Compilation', async () => {
|
||||||
const stats = await fetch(STATOSCOPE_REFERENCE_URL).then((res) => res.text());
|
try {
|
||||||
fs.writeFileSync(path.resolve('./public/reference.json'), stats);
|
const stats = await fetch(STATOSCOPE_REFERENCE_URL).then((res) => res.text());
|
||||||
|
fs.writeFileSync(path.resolve('./public/reference.json'), stats);
|
||||||
|
isReferenceFetched = true;
|
||||||
|
} catch (err) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.warn('Failed to fetch reference statoscope stats: ', err.message);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
}] : []),
|
}] : []),
|
||||||
@ -206,7 +213,7 @@ module.exports = (_env, { mode = 'production' }) => {
|
|||||||
normalizeStats: true,
|
normalizeStats: true,
|
||||||
open: 'file',
|
open: 'file',
|
||||||
extensions: [new WebpackContextExtension()],
|
extensions: [new WebpackContextExtension()],
|
||||||
...(APP_ENV === 'staging' && {
|
...(APP_ENV === 'staging' && isReferenceFetched && {
|
||||||
additionalStats: ['./public/reference.json'],
|
additionalStats: ['./public/reference.json'],
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user