This repository has been archived by the owner on Sep 11, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(build): upgrade to webpack 2
- Loading branch information
David Zukowski
committed
May 16, 2017
1 parent
1a4a71b
commit 9f734b3
Showing
47 changed files
with
2,792 additions
and
3,054 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,4 +1,3 @@ | ||
blueprints/**/files/** | ||
coverage/** | ||
node_modules/** | ||
dist/** | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,7 @@ | ||
.DS_STORE | ||
*.log | ||
|
||
node_modules | ||
|
||
dist | ||
coverage | ||
|
||
.idea/ | ||
.yarn-cache |
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 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,50 @@ | ||
const argv = require('yargs').argv | ||
const webpackConfig = require('./webpack.config') | ||
|
||
const TEST_BUNDLER = './tests/test-bundler.js' | ||
|
||
const karmaConfig = { | ||
basePath: '../', | ||
browsers: ['PhantomJS'], | ||
singleRun: !argv.watch, | ||
coverageReporter: { | ||
reporters: [ | ||
{ type: 'text-summary' }, | ||
], | ||
}, | ||
files: [{ | ||
pattern : TEST_BUNDLER, | ||
watched : false, | ||
served : true, | ||
included : true | ||
}], | ||
frameworks: ['mocha'], | ||
reporters: ['mocha'], | ||
preprocessors: { | ||
[TEST_BUNDLER]: ['webpack'], | ||
}, | ||
logLevel: 'WARN', | ||
browserConsoleLogOptions: { | ||
terminal: true, | ||
format: '%b %T: %m', | ||
level: '', | ||
}, | ||
webpack: { | ||
entry: TEST_BUNDLER, | ||
devtool: 'cheap-module-source-map', | ||
module: webpackConfig.module, | ||
plugins: webpackConfig.plugins, | ||
resolve: webpackConfig.resolve, | ||
externals: { | ||
'react/addons': 'react', | ||
'react/lib/ExecutionEnvironment': 'react', | ||
'react/lib/ReactContext': 'react', | ||
}, | ||
}, | ||
webpackMiddleware: { | ||
stats: 'errors-only', | ||
noInfo: true, | ||
}, | ||
} | ||
|
||
module.exports = (cfg) => cfg.set(karmaConfig) |
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,8 @@ | ||
const chalk = require('chalk') | ||
const figures = require('figures') | ||
|
||
exports.log = (...messages) => console.log(...messages) | ||
exports.error = (...messages) => console.error(chalk.red(figures.cross, ...messages)) | ||
exports.info = (...messages) => console.info(chalk.cyan(figures.info, ...messages)) | ||
exports.success = (...messages) => console.log(chalk.green(figures.tick, ...messages)) | ||
exports.warn = (...messages) => console.warn(chalk.yellow(figures.warning, ...messages)) |
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,49 @@ | ||
const fs = require('fs-extra') | ||
const webpack = require('webpack') | ||
const path = require('path') | ||
const logger = require('../lib/logger') | ||
const webpackConfig = require('../webpack.config') | ||
const project = require('../../project.config') | ||
|
||
// Wrapper around webpack to promisify its compiler and supply friendly logging | ||
const webpackCompiler = (webpackConfig) => | ||
new Promise((resolve, reject) => { | ||
webpack(webpackConfig).run((err, stats) => { | ||
if (err) { | ||
logger.error('Webpack compiler encountered a fatal error.', err) | ||
return reject(err) | ||
} | ||
|
||
const jsonStats = stats.toJson() | ||
logger.info('Webpack compiler finished.') | ||
logger.log(stats.toString({ | ||
colors: true, | ||
chunks: false, | ||
})) | ||
|
||
if (jsonStats.errors.length > 0) { | ||
logger.error('Webpack compiler encountered errors.') | ||
logger.log(jsonStats.errors.join('\n')) | ||
return reject(new Error('Webpack compiler encountered errors')) | ||
} else if (jsonStats.warnings.length > 0) { | ||
logger.warn('Webpack compiler encountered warnings.') | ||
logger.log(jsonStats.warnings.join('\n')) | ||
} | ||
resolve(jsonStats) | ||
}) | ||
}) | ||
|
||
const compile = () => Promise.resolve() | ||
.then(() => logger.info('Starting compiler...')) | ||
.then(() => webpackCompiler(webpackConfig)) | ||
.then(() => { | ||
logger.info('Copying static public assets to output directory.') | ||
fs.copySync( | ||
path.resolve(project.basePath, 'public'), | ||
path.resolve(project.basePath, project.outDir) | ||
) | ||
}) | ||
.then(() => logger.success('Compilation succeeded.')) | ||
.catch((err) => logger.error('Compilation failed.', err)) | ||
|
||
compile() |
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,6 @@ | ||
const logger = require('../lib/logger') | ||
|
||
logger.info('Starting server...') | ||
require('../../server/main').listen(3000, () => { | ||
logger.success('Server is running at http://localhost:3000') | ||
}) |
Oops, something went wrong.