diff --git a/src/server/server.tsx b/src/server/server.tsx
index b372ab8..ff4fb88 100644
--- a/src/server/server.tsx
+++ b/src/server/server.tsx
@@ -30,9 +30,9 @@ const routesUrls = routes.map( route => route.path);
const app = express();
+// @ts-ignore:next-line
+const compiler = webpack(webpackConfig);
if(env === 'development'){
- // @ts-ignore:next-line
- const compiler = webpack(webpackConfig);
const serverConfig = {
serverSideRender: true,
publicPath: webpackConfig.output?.publicPath,
@@ -72,6 +72,8 @@ const setResponse = (html, preloadedState, manifest) => {
const mainBuild = manifest ? manifest['frontend.js'] : 'assets/app.js';
const vendorBuild = manifest ? manifest['vendors.js'] : 'assets/vendor.js';
const manifestJson = manifest ? `` : '';
+ const memoryFs = compiler.outputFileSystem
+ const haveVendor = haveVendorsCss(manifest, memoryFs)
return(`
@@ -84,7 +86,7 @@ const setResponse = (html, preloadedState, manifest) => {
${manifestJson}
- ${haveVendorsCss() ? `` : ''}
+ ${haveVendor ? `` : ''}
App
diff --git a/src/server/utilsServer.ts b/src/server/utilsServer.ts
index ccc695e..64e45d8 100644
--- a/src/server/utilsServer.ts
+++ b/src/server/utilsServer.ts
@@ -1,20 +1,25 @@
import fs from 'fs';
+import config from '../../config';
+
+const { env } = config
export const getHashManifest = () => {
try {
const baseUrl = __dirname.replace(/\/server(.*)/,'');
- const fullURL = `${baseUrl}/assets/manifest-hash.json` ;
- return JSON.parse(fs.readFileSync(fullURL).toString());
+ const fullURL = `${baseUrl}/assets/manifest-hash.json`;
+ const readFileData = JSON.parse(fs.readFileSync(fullURL).toString());
+ return readFileData
}catch(err){
console.error(err);
}
};
-export const haveVendorsCss = () => {
+export const haveVendorsCss = (manifest, memoryFs) => {
try {
const baseUrl = __dirname.replace(/\/server(.*)/,'');
- const fullURL = `${baseUrl}/assets/vendors.css` ;
- fs.readFileSync(fullURL).toString();
+ const fullURL = `${baseUrl}${manifest ? manifest['vendors.css'] : '/build/assets/vendors.css'}`;
+ env === 'production' && fs.readFileSync(fullURL).toString();
+ env === 'development' && memoryFs.readFileSync(fullURL).toString();
return true
}catch(err){
// console.error(err);
diff --git a/webpack.config.ts b/webpack.config.ts
index c8ba900..aed3e6e 100644
--- a/webpack.config.ts
+++ b/webpack.config.ts
@@ -198,7 +198,7 @@ const serverConfig = {
filename: '[path][base].gz',
}),
new MiniCssExtractPlugin({
- filename: 'assets/[name]/app-[fullhash].css',
+ filename: 'assets/[name]-[fullhash].css',
}),
new WebpackManifestPlugin({
fileName: 'assets/manifest-hash.json',