Skip to content

Commit

Permalink
Removed unnecessary code and updated universal-import version
Browse files Browse the repository at this point in the history
  • Loading branch information
akash5474 committed Jun 19, 2018
1 parent 764c1be commit fd65e57
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 180 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ node_modules
*.log
buildClient
buildServer
.vscode
.vscode
.DS_Store
11 changes: 6 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"babel-core": "^6.24.0",
"babel-eslint": "^8.0.1",
"babel-loader": "^7.1.2",
"babel-plugin-universal-import": "^1.2.6",
"babel-plugin-universal-import": "^3.0.0",
"babel-preset-es2015": "^6.24.0",
"babel-preset-react": "^6.23.0",
"babel-preset-stage-2": "^6.22.0",
Expand Down
38 changes: 10 additions & 28 deletions server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,12 @@ require('colors')
const express = require('express')
const webpack = require('webpack')
const noFavicon = require('express-no-favicons')
const webpackDevMiddleware = require('webpack-dev-middleware')
const webpackHotMiddleware = require('webpack-hot-middleware')
const webpackHotServerMiddleware = require('webpack-hot-server-middleware')
const clientConfig = require('../webpack/client.dev')
const serverConfig = require('../webpack/server.dev')
const clientConfigProd = require('../webpack/client.prod')
const serverConfigProd = require('../webpack/server.prod')

const publicPath = clientConfig.output.publicPath
const outputPath = clientConfig.output.path
const DEV = process.env.NODE_ENV === 'development'
const { publicPath } = clientConfigProd.output
const outputPath = clientConfigProd.output.path

const app = express()
app.use(noFavicon())

Expand All @@ -25,25 +20,12 @@ const done = () =>
console.log('BUILD COMPLETE -- Listening @ http://localhost:3000'.magenta)
})

if (DEV) {
const compiler = webpack([clientConfig, serverConfig])
const clientCompiler = compiler.compilers[0]
const options = { publicPath, stats: { colors: true } }

app.use(webpackDevMiddleware(compiler, options))
app.use(webpackHotMiddleware(clientCompiler))
app.use(webpackHotServerMiddleware(compiler))
webpack([clientConfigProd, serverConfigProd]).run((err, stats) => {
const clientStats = stats.toJson().children[0]
const serverRender = require('../buildServer/main.js').default

compiler.plugin('done', done)
}
else {
webpack([clientConfigProd, serverConfigProd]).run((err, stats) => {
const clientStats = stats.toJson().children[0]
const serverRender = require('../buildServer/main.js').default
app.use(publicPath, express.static(outputPath))
app.use(serverRender({ clientStats }))

app.use(publicPath, express.static(outputPath))
app.use(serverRender({ clientStats }))

done()
})
}
done()
})
65 changes: 0 additions & 65 deletions webpack/client.dev.js

This file was deleted.

4 changes: 2 additions & 2 deletions webpack/client.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ module.exports = {
devtool: 'source-map',
entry: [path.resolve(__dirname, '../src/index.js')],
output: {
filename: '[name].[chunkhash].js',
chunkFilename: '[name].[chunkhash].js',
filename: '[name].js',
chunkFilename: '[name].js',
path: path.resolve(__dirname, '../buildClient'),
publicPath: '/static/'
},
Expand Down
78 changes: 0 additions & 78 deletions webpack/server.dev.js

This file was deleted.

0 comments on commit fd65e57

Please sign in to comment.