Update ghu.js.

This commit is contained in:
Lars Jung 2016-06-19 14:08:26 +02:00
parent 2153056266
commit 1fc72d8473

49
ghu.js
View file

@ -10,6 +10,20 @@ const TEST = join(ROOT, 'test');
const BUILD = join(ROOT, 'build'); const BUILD = join(ROOT, 'build');
const mapper = mapfn.p(SRC, BUILD).s('.less', '.css').s('.pug', ''); const mapper = mapfn.p(SRC, BUILD).s('.less', '.css').s('.pug', '');
const webpackCfg = include => ({
module: {
loaders: [
{
include,
loader: 'babel-loader',
query: {
cacheDirectory: true,
presets: ['es2015']
}
}
]
}
});
ghu.defaults('release'); ghu.defaults('release');
@ -49,25 +63,9 @@ ghu.task('lint', 'lint all JavaScript files with eslint', () => {
}); });
ghu.task('build:scripts', runtime => { ghu.task('build:scripts', runtime => {
const webpackConfig = {
output: {},
module: {
loaders: [
{
include: [SRC],
loader: 'babel',
query: {
presets: ['es2015'],
cacheDirectory: true
}
}
]
}
};
return read(`${SRC}/_h5ai/public/js/scripts.js`) return read(`${SRC}/_h5ai/public/js/scripts.js`)
.then(newerThan(mapper, `${SRC}/_h5ai/public/js/**`)) .then(newerThan(mapper, `${SRC}/_h5ai/public/js/**`))
.then(webpack(webpackConfig, {showStats: false})) .then(webpack(webpackCfg([SRC]), {showStats: false}))
.then(wrap('\n\n// @include "pre.js"\n\n')) .then(wrap('\n\n// @include "pre.js"\n\n'))
.then(includeit()) .then(includeit())
.then(ife(() => runtime.args.production, uglify())) .then(ife(() => runtime.args.production, uglify()))
@ -119,21 +117,6 @@ ghu.task('build:copy', runtime => {
}); });
ghu.task('build:tests', ['build:styles'], 'build the test suite', () => { ghu.task('build:tests', ['build:styles'], 'build the test suite', () => {
const webpackConfig = {
module: {
loaders: [
{
include: [TEST],
loader: 'babel',
query: {
presets: ['es2015'],
cacheDirectory: true
}
}
]
}
};
return Promise.all([ return Promise.all([
read(`${BUILD}/_h5ai/public/css/styles.css`) read(`${BUILD}/_h5ai/public/css/styles.css`)
.then(newerThan(`${BUILD}/test/h5ai-styles.css`)) .then(newerThan(`${BUILD}/test/h5ai-styles.css`))
@ -144,7 +127,7 @@ ghu.task('build:tests', ['build:styles'], 'build the test suite', () => {
.then(write(`${BUILD}/test/tests.html`, {overwrite: true})), .then(write(`${BUILD}/test/tests.html`, {overwrite: true})),
read(`${TEST}: tests.js`) read(`${TEST}: tests.js`)
.then(webpack(webpackConfig, {showStats: false})) .then(webpack(webpackCfg([SRC, TEST]), {showStats: false}))
.then(wrap(`\n\n// @include "${SRC}/**/js/pre.js"\n\n`)) .then(wrap(`\n\n// @include "${SRC}/**/js/pre.js"\n\n`))
.then(includeit()) .then(includeit())
.then(write(mapfn.p(TEST, `${BUILD}/test`), {overwrite: true})) .then(write(mapfn.p(TEST, `${BUILD}/test`), {overwrite: true}))