Skip to content

Commit

Permalink
Start server before starting client compile
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredpalmer committed May 20, 2017
1 parent a8c0d74 commit eb22241
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
language: node_js
node_js:
- 6
script: yarn run e2e --runInBand
script: yarn run e2e -- --runInBand
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"testPathIgnorePatterns": [
"<rootDir>/coverage/",
"<rootDir>/node_modules/",
"<rootDir>/examples/"
"<rootDir>/examples/",
"<rootDir>/test/"
],
"collectCoverageFrom": [
"**/*.js"
Expand Down
16 changes: 6 additions & 10 deletions packages/razzle/config/FriendlyErrorsPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,20 @@ class WebpackErrorsPlugin {
}
}

if (messages.errors.length) {
if (
rawMessages.errors &&
if (
messages.errors.length &&
!(rawMessages.errors &&
rawMessages.errors.length > 0 &&
(rawMessages.errors[0].includes('assets.json') ||
rawMessages.errors[0].includes("Module not found: Can't resolve"))
) {
return;
}

rawMessages.errors[0].includes("Module not found: Can't resolve")))
) {
messages.errors.forEach(e => {
logger.error(
`Failed to compile ${this.target} with ${messages.errors.length} errors`,
e
);
});

return;
// return;
}

if (messages.warnings.length) {
Expand Down
22 changes: 14 additions & 8 deletions packages/razzle/config/create-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,24 +255,30 @@ module.exports = (
// Configure webpack-dev-server to serve our client-side bundle from
// http://${dotenv.raw.HOST}:3001
config.devServer = {
host: dotenv.raw.HOST,
disableHostCheck: true,
clientLogLevel: 'none',
// Enable gzip compression of generated files.
compress: true,
// watchContentBase: true,
headers: {
'Access-Control-Allow-Origin': '*',
},
historyApiFallback: {
// Paths with dots should still use the history fallback.
// See https://github.com/facebookincubator/create-react-app/issues/387.
disableDotRule: true,
},
host: dotenv.raw.HOST,
hot: true,
noInfo: true,
overlay: false,
port: devServerPort,
quiet: true,
// Reportedly, this avoids CPU overload on some systems.
// https://github.com/facebookincubator/create-react-app/issues/293
watchOptions: {
ignored: /node_modules/,
},
// Enable gzip compression of generated files.
compress: true,
port: devServerPort,
noInfo: true,
quiet: true,
historyApiFallback: true,
hot: true,
};
// Add client-only development plugins
config.plugins = [
Expand Down
21 changes: 11 additions & 10 deletions packages/razzle/scripts/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,19 @@ if (razzle.modify) {
);
}

const serverCompiler = compile(serverConfig);

// Start our server webpack instance in watch mode.
serverCompiler.watch(
{
quiet: true,
stats: 'none',
},
stats => {}
);

// Compile our assets with webpack
const clientCompiler = compile(clientConfig);
const serverCompiler = compile(serverConfig);

// Create a new instance of Webpack-dev-server for our client assets.
// This will actually run on a different port than the users app.
Expand All @@ -68,15 +78,6 @@ clientDevServer.listen(
}
);

// Start our server webpack instance in watch mode.
serverCompiler.watch(
{
quiet: true,
stats: 'none',
},
stats => {}
);

// Webpack compile in a try-catch
function compile(config) {
let compiler;
Expand Down

0 comments on commit eb22241

Please sign in to comment.