diff --git a/server/utils/prefetchTags.js b/server/utils/prefetchTags.js
index 4534e84cd..b48720a4b 100644
--- a/server/utils/prefetchTags.js
+++ b/server/utils/prefetchTags.js
@@ -1,5 +1,7 @@
// @flow
import React from 'react';
+import fs from 'fs';
+import path from 'path';
import webpackConfig from '../../webpack.config';
const PUBLIC_PATH = webpackConfig.output.publicPath;
@@ -8,26 +10,26 @@ const prefetchTags = [
,
];
-if (process.env.NODE_ENV === 'production') {
- try {
- const manifest = require('../../dist/manifest.json');
- Object.values(manifest).forEach(filename => {
- if (typeof filename !== 'string') return;
- if (filename.endsWith('.js')) {
- prefetchTags.push(
-
- );
- } else if (filename.endsWith('.css')) {
- prefetchTags.push(
-
- );
- }
- });
- } catch (_e) {
- console.warn(
- 'Warning: Unable to load dist/manifest.json. Please `yarn build` before starting production server'
- );
- }
+try {
+ const manifest = fs.readFileSync(
+ path.join(__dirname, '../../dist/manifest.json'),
+ 'utf8'
+ );
+ const manifestData = JSON.parse(manifest);
+ Object.values(manifestData).forEach(filename => {
+ if (typeof filename !== 'string') return;
+ if (filename.endsWith('.js')) {
+ prefetchTags.push(
+
+ );
+ } else if (filename.endsWith('.css')) {
+ prefetchTags.push(
+
+ );
+ }
+ });
+} catch (_e) {
+ // no-op
}
export default prefetchTags;