This repository has been archived by the owner on Feb 19, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Changing config folder to configuration
- Using express instead of webpack dev server - Adding coverage - Adding prod mode
- Loading branch information
1 parent
2d036e4
commit fc74fc5
Showing
16 changed files
with
205 additions
and
134 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
# dependencies | ||
node_modules | ||
|
||
#coverage | ||
coverage | ||
.nyc_output | ||
|
||
# production | ||
build | ||
|
||
|
File renamed without changes.
File renamed without changes.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module.exports = { | ||
babelrc: false, | ||
presets: [ | ||
'babel-preset-es2015', | ||
'babel-preset-stage-0', | ||
'babel-preset-react', | ||
], | ||
plugins: ['istanbul'], | ||
}; |
File renamed without changes.
File renamed without changes.
This file contains 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
File renamed without changes.
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* eslint-disable */ | ||
var path = require('path'); | ||
var chalk = require('chalk'); | ||
var express = require('express'); | ||
var favicon = require('serve-favicon'); | ||
var webpack = require('webpack'); | ||
var config = require('../configuration/webpack.config.dev'); | ||
var utils = require('./utils'); | ||
|
||
process.env.NODE_ENV = 'development'; | ||
|
||
var PORT = process.env.PORT || 3000; | ||
|
||
// Set up compiler | ||
|
||
var compiler = webpack(config); | ||
|
||
compiler.plugin('invalid', () => { | ||
utils.clearConsole(); | ||
console.log('Compiling...'); | ||
}); | ||
|
||
compiler.plugin('done', (stats) => { | ||
utils.formatStats(stats, PORT); | ||
}); | ||
|
||
// Launch server | ||
|
||
var app = express(); | ||
|
||
app.use(require('webpack-dev-middleware')(compiler, { | ||
noInfo: true, | ||
publicPath: config.output.publicPath, | ||
})); | ||
|
||
app.use(require('webpack-hot-middleware')(compiler)); | ||
|
||
app.use(favicon('./favicon.png')); | ||
|
||
app.get('*', (req, res) => { | ||
res.sendFile(path.resolve('index.html')); | ||
}); | ||
|
||
app.listen(PORT, (err) => { | ||
if (err) { | ||
console.log(err); | ||
return; | ||
} | ||
|
||
utils.clearConsole(); | ||
console.log(chalk.cyan('Starting the development server...')); | ||
console.log(); | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* eslint-disable */ | ||
var path = require('path'); | ||
var chalk = require('chalk'); | ||
var express = require('express'); | ||
var favicon = require('serve-favicon'); | ||
var utils = require('./utils'); | ||
|
||
var PORT = process.env.PORT || 80; | ||
|
||
// Launch server | ||
|
||
var app = express(); | ||
|
||
app.use('/static', express.static('./build/static')); | ||
|
||
app.use(favicon('./build/favicon.png')); | ||
|
||
app.get('*', (req, res) => { | ||
res.sendFile(path.resolve('./build/index.html')); | ||
}); | ||
|
||
app.listen(PORT, (err) => { | ||
if (err) { | ||
console.log(err); | ||
return; | ||
} | ||
|
||
utils.clearConsole(); | ||
console.log(chalk.cyan('Production server started on port ' + PORT)); | ||
console.log(); | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* eslint-disable */ | ||
var chalk = require('chalk'); | ||
|
||
var friendlySyntaxErrorLabel = 'Syntax error:'; | ||
|
||
function isLikelyASyntaxError(message) { | ||
return message.indexOf(friendlySyntaxErrorLabel) !== -1; | ||
} | ||
|
||
function formatMessage(message) { | ||
return message | ||
.replace( | ||
'Module build failed: SyntaxError:', | ||
friendlySyntaxErrorLabel | ||
) | ||
.replace( | ||
/Module not found: Error: Cannot resolve 'file' or 'directory'/, | ||
'Module not found:' | ||
) | ||
.replace(/^\s*at\s.*:\d+:\d+[\s\)]*\n/gm, '') // at ... ...:x:y | ||
.replace('./~/css-loader!./~/postcss-loader!', ''); | ||
} | ||
var clearConsole = () => { | ||
process.stdout.write('\x1bc'); | ||
}; | ||
|
||
var formatStats = (stats, port) => { | ||
clearConsole(); | ||
var hasErrors = stats.hasErrors(); | ||
var hasWarnings = stats.hasWarnings(); | ||
if (!hasErrors && !hasWarnings) { | ||
console.log(chalk.green('Compiled successfully!')); | ||
console.log(); | ||
console.log('The app is running at http://localhost:' + port + '/'); | ||
console.log(); | ||
return; | ||
} | ||
|
||
var json = stats.toJson(); | ||
var formattedErrors = json.errors.map(message => | ||
'Error in ' + formatMessage(message) | ||
); | ||
var formattedWarnings = json.warnings.map(message => | ||
'Warning in ' + formatMessage(message) | ||
); | ||
|
||
if (hasErrors) { | ||
console.log(chalk.red('Failed to compile.')); | ||
console.log(); | ||
if (formattedErrors.some(isLikelyASyntaxError)) { | ||
formattedErrors = formattedErrors.filter(isLikelyASyntaxError); | ||
} | ||
formattedErrors.forEach(message => { | ||
console.log(message); | ||
console.log(); | ||
}); | ||
return; | ||
} | ||
|
||
if (hasWarnings) { | ||
console.log(chalk.yellow('Compiled with warnings.')); | ||
console.log(); | ||
formattedWarnings.forEach(message => { | ||
console.log(message); | ||
console.log(); | ||
}); | ||
|
||
console.log('You may use special comments to disable some warnings.'); | ||
console.log('Use ' + chalk.yellow('// eslint-disable-next-line') + ' to ignore the next line.'); | ||
console.log('Use ' + chalk.yellow('/* eslint-disable */') + ' to ignore all warnings in a file.'); | ||
} | ||
}; | ||
|
||
module.exports = { | ||
formatStats: formatStats, | ||
clearConsole: clearConsole, | ||
}; | ||
|
Oops, something went wrong.