Skip to content

Commit

Permalink
feat(server): use babel-register instead of babel-node for prod mode
Browse files Browse the repository at this point in the history
  • Loading branch information
kiki-le-singe committed Dec 20, 2016
1 parent 299fd60 commit ebbaf28
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 27 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,15 @@
}
},
"start:server": {
"command": "nodemon ./node_modules/.bin/babel-node -- src/server/index",
"command": "nodemon src/server/index",
"env": {
"NODE_ENV": "development",
"NODE_PATH": "src",
"DEBUG": "app:*"
}
},
"prod": {
"command": "babel-node src/server/index",
"command": "node src/server/index",
"env": {
"NODE_ENV": "production",
"NODE_PATH": "src",
Expand Down
27 changes: 2 additions & 25 deletions src/server/index.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,2 @@
import WebpackIsomorphicTools from 'webpack-isomorphic-tools'

import isomorphicToolsConfig from '../../webpack/isomorphic.tools.config'
import projectConfig, { paths } from '../../config'

const projectBasePath = paths('base')

/**
* Define isomorphic constants.
*/
global.__CLIENT__ = false
global.__SERVER__ = true
global.__DEV__ = projectConfig.__DEV__
global.__PROD__ = projectConfig.__PROD__

// https://github.com/halt-hammerzeit/webpack-isomorphic-tools#mainjs
global.webpackIsomorphicTools =
new WebpackIsomorphicTools(isomorphicToolsConfig)
.server(projectBasePath, () => {
if (__DEV__) {
require('./server.dev')
} else {
require('./server.prod')
}
})
require('babel-core/register')
require('./server')
25 changes: 25 additions & 0 deletions src/server/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import WebpackIsomorphicTools from 'webpack-isomorphic-tools'

import isomorphicToolsConfig from '../../webpack/isomorphic.tools.config'
import projectConfig, { paths } from '../../config'

const projectBasePath = paths('base')

/**
* Define isomorphic constants.
*/
global.__CLIENT__ = false
global.__SERVER__ = true
global.__DEV__ = projectConfig.__DEV__
global.__PROD__ = projectConfig.__PROD__

// https://github.com/halt-hammerzeit/webpack-isomorphic-tools#mainjs
global.webpackIsomorphicTools =
new WebpackIsomorphicTools(isomorphicToolsConfig)
.server(projectBasePath, () => {
if (__DEV__) {
require('./server.dev')
} else {
require('./server.prod')
}
})

0 comments on commit ebbaf28

Please sign in to comment.