Created
November 24, 2015 14:14
-
-
Save msikma/ba66530df4594d3b7314 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'); | |
var path = require('path'); | |
var WebpackIsomorphicTools = require('webpack-isomorphic-tools'); | |
var isoToolsOptions = require('../../tasks/webpack/webpack-isomorphic-tools'); | |
var babelOptions = JSON.parse(fs.readFileSync('./.babelrc', 'utf8')); | |
// todo: describe | |
var pipingOptions = { | |
hook: true, | |
ignore: /(\/\.|~$|\.json|\.scss$)/i | |
}; | |
// Register Babel require hook to compile ES2015 files on the fly. | |
require('babel-core/register')(babelOptions); | |
// Define isomorphic constants. | |
global.__CLIENT__ = false; | |
global.__SERVER__ = true; | |
global.__DEVELOPMENT__ = process.env.NODE_ENV !== 'production'; | |
if (__DEVELOPMENT__) { | |
if (!require('piping')(pipingOptions)) { | |
// Use a top-level return to end the process without killing | |
// the development process chain. | |
return; | |
} | |
} | |
// Uses webpack-isomorphic-tools to simplify server-side rendering. | |
// See <https://github.com/halt-hammerzeit/webpack-isomorphic-tools>. | |
// todo: test | |
global.webpackIsomorphicTools = new WebpackIsomorphicTools(isoToolsOptions) | |
.development(__DEVELOPMENT__) | |
.server(path.resolve(__dirname, '../..'), function() { | |
require('../src/server'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment