@@ -12,7 +12,7 @@ import webpackHotMiddleware from 'webpack-hot-middleware';
12
12
// Initialize the Express App
13
13
const app = new Express ( ) ;
14
14
15
- if ( process . env . NODE_ENV !== 'production ') {
15
+ if ( process . env . NODE_ENV === 'development ') {
16
16
const compiler = webpack ( config ) ;
17
17
app . use ( webpackDevMiddleware ( compiler , { noInfo : true , publicPath : config . output . publicPath } ) ) ;
18
18
app . use ( webpackHotMiddleware ( compiler ) ) ;
@@ -47,16 +47,16 @@ mongoose.connect(serverConfig.mongoURL, (error) => {
47
47
// Apply body Parser and server public assets and routes
48
48
app . use ( bodyParser . json ( { limit : '20mb' } ) ) ;
49
49
app . use ( bodyParser . urlencoded ( { limit : '20mb' , extended : false } ) ) ;
50
- app . use ( Express . static ( path . resolve ( __dirname , '../static ' ) ) ) ;
50
+ app . use ( Express . static ( path . resolve ( __dirname , '../dist ' ) ) ) ;
51
51
app . use ( '/api' , posts ) ;
52
52
53
53
// Render Initial HTML
54
54
const renderFullPage = ( html , initialState ) => {
55
55
const head = Helmet . rewind ( ) ;
56
56
57
57
// Import Manifests
58
- const assetsManifest = process . env . NODE_ENV === 'production' ? require ( '../static/ dist/manifest.json' ) : { } ; // eslint-disable-line
59
- const chunkManifest = process . env . NODE_ENV === 'production' ? require ( '../static/ dist/chunk-manifest.json' ) : { } ; // eslint-disable-line
58
+ const assetsManifest = process . env . NODE_ENV === 'production' ? require ( '../dist/manifest.json' ) : { } ; // eslint-disable-line
59
+ const chunkManifest = process . env . NODE_ENV === 'production' ? require ( '../dist/chunk-manifest.json' ) : { } ; // eslint-disable-line
60
60
61
61
return `
62
62
<!doctype html>
@@ -68,7 +68,7 @@ const renderFullPage = (html, initialState) => {
68
68
${ head . link . toString ( ) }
69
69
${ head . script . toString ( ) }
70
70
71
- <link rel=" stylesheet" href='/dist/ app.css' />
71
+ ${ process . env . NODE_ENV === 'production' ? ` <link rel=' stylesheet' href='${ assetsManifest [ '/ app.css'] } ' />` : '' }
72
72
<link href='https://fonts.googleapis.com/css?family=Lato:400,300,700' rel='stylesheet' type='text/css'/>
73
73
<link rel="shortcut icon" href="http://res.cloudinary.com/hashnode/image/upload/v1455629445/static_imgs/mern/mern-favicon-circle-fill.png" type="image/png" />
74
74
</head>
@@ -77,12 +77,12 @@ const renderFullPage = (html, initialState) => {
77
77
<script>
78
78
window.__INITIAL_STATE__ = ${ JSON . stringify ( initialState ) } ;
79
79
${ process . env . NODE_ENV === 'production' ?
80
- `//<![CDATA[
80
+ `//<![CDATA[
81
81
window.webpackManifest = ${ JSON . stringify ( chunkManifest ) } ;
82
82
//]]>` : '' }
83
83
</script>
84
- <script src='${ process . env . NODE_ENV === 'production' ? assetsManifest [ '/dist/ vendor.js' ] : '/dist /vendor.js' } '></script>
85
- <script src='${ process . env . NODE_ENV === 'production' ? assetsManifest [ '/dist/ app.js' ] : '/dist /app.js' } '></script>
84
+ <script src='${ process . env . NODE_ENV === 'production' ? assetsManifest [ '/vendor.js' ] : '/vendor.js' } '></script>
85
+ <script src='${ process . env . NODE_ENV === 'production' ? assetsManifest [ '/app.js' ] : '/app.js' } '></script>
86
86
</body>
87
87
</html>
88
88
` ;
0 commit comments