-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathrun.js
More file actions
65 lines (56 loc) · 2.08 KB
/
Copy pathrun.js
File metadata and controls
65 lines (56 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/**
* React Static Boilerplate
* https://github.com/kriasoft/react-static-boilerplate
*
* Copyright © 2015-present Kriasoft, LLC. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE.txt file in the root directory of this source tree.
*/
/* eslint-disable no-console, global-require */
const del = require('del')
const webpack = require('webpack')
// TODO: Update configuration settings
// const config = {
// title: 'React Static Boilerplate', // Your website title
// url: 'https://rsb.kriasoft.com', // Your website URL
// project: 'react-static-boilerplate', // Firebase project. See README.md -> How to Deploy
// trackingID: 'UA-XXXXX-Y', // Google Analytics Site's ID
// }
const tasks = new Map() // The collection of automation tasks ('clean', 'build', 'publish', etc.)
function run(task) {
const start = new Date()
console.log(`Starting '${task}'...`)
return Promise.resolve().then(() => tasks.get(task)()).then(() => {
console.log(`Finished '${task}' after ${new Date().getTime() - start.getTime()}ms`)
}, err => console.error(err.stack))
}
//
// Clean up the output directory
// -----------------------------------------------------------------------------
tasks.set('clean', () => del(['dist/*', '!dist/.git'], { dot: true }))
//
// Bundle JavaScript, CSS and image files with Webpack
// -----------------------------------------------------------------------------
tasks.set('bundle', () => {
const webpackConfig = require('./webpack.config')
return new Promise((resolve, reject) => {
webpack(webpackConfig).run((err, stats) => {
if (err) {
reject(err)
} else {
console.log(stats.toString(webpackConfig.stats))
resolve()
}
})
})
})
//
// Build website into a distributable format
// -----------------------------------------------------------------------------
tasks.set('build', () => {
global.DEBUG = process.argv.includes('--debug') || false
return Promise.resolve()
.then(() => run('clean'))
.then(() => run('bundle'))
})