2018-09-30 23:02:10 +00:00
|
|
|
const notifier = require('node-notifier')
|
2019-01-18 21:00:15 +00:00
|
|
|
const babelOpts = {
|
|
|
|
presets: [
|
|
|
|
['@babel/preset-env', {
|
|
|
|
modules: 'commonjs',
|
|
|
|
'targets': {
|
|
|
|
'browsers': ['IE 11']
|
|
|
|
}
|
|
|
|
}]
|
|
|
|
],
|
|
|
|
plugins: [
|
|
|
|
['@babel/plugin-transform-runtime', {
|
|
|
|
corejs: 2,
|
|
|
|
helpers: true,
|
|
|
|
regenerator: true,
|
|
|
|
useESModules: false
|
|
|
|
}]
|
|
|
|
]
|
|
|
|
}
|
2018-09-30 23:02:10 +00:00
|
|
|
|
|
|
|
export async function compile (task) {
|
2018-10-02 22:08:57 +00:00
|
|
|
await task.parallel(['bin', 'server', 'nextbuild', 'nextbuildstatic', 'pages', 'lib', 'client'])
|
2018-09-30 23:02:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export async function bin (task, opts) {
|
2018-12-15 21:55:59 +00:00
|
|
|
await task.source(opts.src || 'bin/*').typescript({module: 'commonjs', stripExtension: true}).target('dist/bin', {mode: '0755'})
|
2018-09-30 23:02:10 +00:00
|
|
|
notify('Compiled binaries')
|
|
|
|
}
|
|
|
|
|
|
|
|
export async function lib (task, opts) {
|
2018-12-13 00:00:46 +00:00
|
|
|
await task.source(opts.src || 'lib/**/*.+(js|ts|tsx)').typescript({module: 'commonjs'}).target('dist/lib')
|
2018-09-30 23:02:10 +00:00
|
|
|
notify('Compiled lib files')
|
|
|
|
}
|
|
|
|
|
|
|
|
export async function server (task, opts) {
|
2018-12-13 00:00:46 +00:00
|
|
|
await task.source(opts.src || 'server/**/*.+(js|ts|tsx)').typescript({module: 'commonjs'}).target('dist/server')
|
2018-09-30 23:02:10 +00:00
|
|
|
notify('Compiled server files')
|
|
|
|
}
|
|
|
|
|
|
|
|
export async function nextbuild (task, opts) {
|
2018-12-13 00:00:46 +00:00
|
|
|
await task.source(opts.src || 'build/**/*.+(js|ts|tsx)').typescript({module: 'commonjs'}).target('dist/build')
|
2018-09-30 23:02:10 +00:00
|
|
|
notify('Compiled build files')
|
|
|
|
}
|
|
|
|
|
|
|
|
export async function client (task, opts) {
|
2019-01-18 21:00:15 +00:00
|
|
|
await task.source(opts.src || 'client/**/*.+(js|ts|tsx)').typescript({module: 'commonjs'}).babel(babelOpts).target('dist/client')
|
2018-09-30 23:02:10 +00:00
|
|
|
notify('Compiled client files')
|
|
|
|
}
|
|
|
|
|
|
|
|
// export is a reserved keyword for functions
|
|
|
|
export async function nextbuildstatic (task, opts) {
|
2018-12-13 00:00:46 +00:00
|
|
|
await task.source(opts.src || 'export/**/*.+(js|ts|tsx)').typescript({module: 'commonjs'}).target('dist/export')
|
2018-09-30 23:02:10 +00:00
|
|
|
notify('Compiled export files')
|
|
|
|
}
|
|
|
|
|
2018-10-02 22:08:57 +00:00
|
|
|
export async function pages (task, opts) {
|
2019-01-18 21:00:15 +00:00
|
|
|
await task.source(opts.src || 'pages/**/*.+(js|ts|tsx)').typescript({module: 'commonjs'}).babel(babelOpts).target('dist/pages')
|
2018-09-30 23:02:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export async function build (task) {
|
2018-10-02 22:08:57 +00:00
|
|
|
await task.serial(['compile'])
|
2018-09-30 23:02:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export default async function (task) {
|
2018-11-30 12:10:30 +00:00
|
|
|
await task.clear('dist')
|
2018-09-30 23:02:10 +00:00
|
|
|
await task.start('build')
|
|
|
|
await task.watch('bin/*', 'bin')
|
2018-12-13 00:00:46 +00:00
|
|
|
await task.watch('pages/**/*.+(js|ts|tsx)', 'pages')
|
|
|
|
await task.watch('server/**/*.+(js|ts|tsx)', 'server')
|
|
|
|
await task.watch('build/**/*.+(js|ts|tsx)', 'nextbuild')
|
|
|
|
await task.watch('export/**/*.+(js|ts|tsx)', 'nextexport')
|
|
|
|
await task.watch('client/**/*.+(js|ts|tsx)', 'client')
|
|
|
|
await task.watch('lib/**/*.+(js|ts|tsx)', 'lib')
|
2018-09-30 23:02:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export async function release (task) {
|
|
|
|
await task.clear('dist').start('build')
|
|
|
|
}
|
|
|
|
|
|
|
|
// notification helper
|
|
|
|
function notify (msg) {
|
|
|
|
return notifier.notify({
|
|
|
|
title: '▲ Next',
|
|
|
|
message: msg,
|
|
|
|
icon: false
|
|
|
|
})
|
|
|
|
}
|