Skip to content
This repository was archived by the owner on Sep 11, 2018. It is now read-only.

Commit c58c0c3

Browse files
author
David Zukowski
committed
refactor(build): upgrade to webpack 2
1 parent 1a4a71b commit c58c0c3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+2884
-3092
lines changed

.eslintignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
blueprints/**/files/**
21
coverage/**
32
node_modules/**
43
dist/**

.eslintrc

+3-2
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@
1919
"__COVERAGE__" : false
2020
},
2121
"rules": {
22-
"key-spacing" : 0,
22+
"key-spacing" : "off",
2323
"jsx-quotes" : [2, "prefer-single"],
2424
"max-len" : [2, 120, 2],
25-
"object-curly-spacing" : [2, "always"]
25+
"object-curly-spacing" : [2, "always"],
26+
"comma-dangle" : "off"
2627
}
2728
}

.gitignore

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
.DS_STORE
22
*.log
3-
43
node_modules
5-
64
dist
75
coverage
8-
96
.idea/
7+
.yarn-cache

.travis.yml

+5-7
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,14 @@ node_js:
44
- "6"
55

66
cache:
7+
yarn: true
78
directories:
89
- node_modules
910

10-
install:
11-
- npm install -g yarn
12-
- yarn install
13-
1411
script:
15-
- npm run deploy:dev
16-
- npm run deploy:prod
12+
- yarn lint
13+
- yarn test
14+
- yarn build
1715

1816
after_success:
19-
- npm run codecov
17+
- yarn codecov

README.md

+76-119
Large diffs are not rendered by default.

bin/compile.js

-56
This file was deleted.

bin/dev-server.js

-6
This file was deleted.

build/karma.config.js

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
const argv = require('yargs').argv
2+
const webpackConfig = require('./webpack.config')
3+
4+
const TEST_BUNDLER = './tests/test-bundler.js'
5+
6+
const karmaConfig = {
7+
basePath: '../',
8+
browsers: ['PhantomJS'],
9+
singleRun: !argv.watch,
10+
coverageReporter: {
11+
reporters: [
12+
{ type: 'text-summary' },
13+
],
14+
},
15+
files: [{
16+
pattern : TEST_BUNDLER,
17+
watched : false,
18+
served : true,
19+
included : true
20+
}],
21+
frameworks: ['mocha'],
22+
reporters: ['mocha'],
23+
preprocessors: {
24+
[TEST_BUNDLER]: ['webpack'],
25+
},
26+
logLevel: 'WARN',
27+
browserConsoleLogOptions: {
28+
terminal: true,
29+
format: '%b %T: %m',
30+
level: '',
31+
},
32+
webpack: {
33+
entry: TEST_BUNDLER,
34+
devtool: 'cheap-module-source-map',
35+
module: webpackConfig.module,
36+
plugins: webpackConfig.plugins,
37+
resolve: webpackConfig.resolve,
38+
externals: {
39+
'react/addons': 'react',
40+
'react/lib/ExecutionEnvironment': 'react',
41+
'react/lib/ReactContext': 'react',
42+
},
43+
},
44+
webpackMiddleware: {
45+
stats: 'errors-only',
46+
noInfo: true,
47+
},
48+
}
49+
50+
module.exports = (cfg) => cfg.set(karmaConfig)

build/lib/logger.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const chalk = require('chalk')
2+
const figures = require('figures')
3+
4+
exports.log = (...messages) => console.log(...messages)
5+
exports.error = (...messages) => console.error(chalk.red(figures.cross, ...messages))
6+
exports.info = (...messages) => console.info(chalk.cyan(figures.info, ...messages))
7+
exports.success = (...messages) => console.log(chalk.green(figures.tick, ...messages))
8+
exports.warn = (...messages) => console.warn(chalk.yellow(figures.warning, ...messages))

build/scripts/compile.js

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
const fs = require('fs-extra')
2+
const path = require('path')
3+
const chalk = require('chalk')
4+
const webpack = require('webpack')
5+
const logger = require('../lib/logger')
6+
const webpackConfig = require('../webpack.config')
7+
const project = require('../../project.config')
8+
9+
const runWebpackCompiler = (webpackConfig) =>
10+
new Promise((resolve, reject) => {
11+
webpack(webpackConfig).run((err, stats) => {
12+
if (err) {
13+
logger.error('Webpack compiler encountered a fatal error.', err)
14+
return reject(err)
15+
}
16+
17+
const jsonStats = stats.toJson()
18+
if (jsonStats.errors.length > 0) {
19+
logger.error('Webpack compiler encountered errors.')
20+
logger.log(jsonStats.errors.join('\n'))
21+
return reject(new Error('Webpack compiler encountered errors'))
22+
} else if (jsonStats.warnings.length > 0) {
23+
logger.warn('Webpack compiler encountered warnings.')
24+
logger.log(jsonStats.warnings.join('\n'))
25+
}
26+
resolve(stats)
27+
})
28+
})
29+
30+
const compile = () => Promise.resolve()
31+
.then(() => logger.info('Starting compiler...'))
32+
.then(() => logger.info('Target application environment: ' + chalk.bold(project.env)))
33+
.then(() => runWebpackCompiler(webpackConfig))
34+
.then((stats) => {
35+
logger.info(`Copying static assets from ./public to ./${project.outDir}.`)
36+
fs.copySync(
37+
path.resolve(project.basePath, 'public'),
38+
path.resolve(project.basePath, project.outDir)
39+
)
40+
return stats
41+
})
42+
.then((stats) => {
43+
if (project.verbose) {
44+
logger.log(stats.toString({
45+
colors: true,
46+
chunks: false,
47+
}))
48+
}
49+
logger.success(`Compiler finished successfully! See ./${project.outDir}.`)
50+
})
51+
.catch((err) => logger.error('Compiler encountered errors.', err))
52+
53+
compile()

build/scripts/start.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const logger = require('../lib/logger')
2+
3+
logger.info('Starting server...')
4+
require('../../server/main').listen(3000, () => {
5+
logger.success('Server is running at http://localhost:3000')
6+
})

0 commit comments

Comments
 (0)