Skip to content

Commit c6d3205

Browse files
committed
Add startup banner to build
1 parent ecc6d16 commit c6d3205

File tree

5 files changed

+55
-5
lines changed

5 files changed

+55
-5
lines changed

default-webpack.config.js

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,22 @@
1616
*/
1717

1818
const path = require('path');
19+
const fs = require('fs-extra');
20+
const webpack = require('webpack');
21+
const GitRevisionPlugin = require('git-revision-webpack-plugin');
22+
23+
const gitRevisions = new GitRevisionPlugin({lightweightTags: true});
24+
25+
const packageJson = fs.readJsonSync(path.join(process.cwd(), 'package.json'));
26+
27+
const version = {
28+
git: gitRevisions.version(),
29+
branch: gitRevisions.branch(),
30+
version: packageJson.version,
31+
name: packageJson.name
32+
};
33+
34+
console.log(version);
1935

2036
module.exports = function (input, output) {
2137
return {
@@ -44,7 +60,6 @@ module.exports = function (input, output) {
4460
interpolate: true,
4561
// minimize: true
4662
},
47-
4863
},
4964
{
5065
loader: 'htmlmin-loader',
@@ -113,6 +128,12 @@ module.exports = function (input, output) {
113128
filename: output,
114129
path: path.resolve(__dirname, 'dist')
115130
},
116-
devtool: 'source-map'
131+
devtool: 'source-map',
132+
plugins: [
133+
new webpack.BannerPlugin({
134+
raw: true,
135+
banner: `console.log("🚀 Starting ${version.name} ${version.version} (git: ${version.git} ${version.branch}) 🚀");`
136+
})
137+
]
117138
}
118139
};

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@
1717
"use strict";
1818

1919
module.exports = {
20-
gulp: require('./runner/gulp')
20+
gulp: require('./runner/gulp'),
2121
};

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
"css-loader": "^0.26.2",
1616
"ejs-compiled-loader": "^2.0.0",
1717
"file-loader": "^0.10.1",
18+
"fs-extra": "^3.0.1",
19+
"git-revision-webpack-plugin": "^2.5.1",
1820
"gulp": "^3.9.1",
1921
"gulp-babel": "^6.1.2",
2022
"gulp-cssmin": "^0.1.7",

runner/gulp.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ module.exports = function initGulp(gulp, opts) {
7474
gulp.task('wc:build', buildTasks);
7575
};
7676

77+
module.exports.defaultWebpackConfig = function() {
78+
return require('../default-webpack.config')
79+
};
80+
7781
function initJs(gulp, jsConfig, componentName, outputDir) {
7882
const webpackStream = require('webpack-stream');
7983
const babel = require('gulp-babel');
@@ -102,8 +106,9 @@ function initJs(gulp, jsConfig, componentName, outputDir) {
102106
.pipe(sourcemaps.init({loadMaps: true}))
103107
.pipe(through.obj(function (file, enc, cb) {//do NOT change this to an arrow function!
104108
//Don't pipe through any source map files as they'll be handled by gulp-sourcemaps
105-
let isSourceMap = /\.map$/.test(file.path);
106-
if (!isSourceMap) this.push(file);
109+
if (file.extname === '.js') {
110+
this.push(file);
111+
}
107112
cb();
108113
}))
109114
.pipe(babel({

yarn.lock

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2474,6 +2474,14 @@ fs-extra@1.0.0:
24742474
jsonfile "^2.1.0"
24752475
klaw "^1.0.0"
24762476

2477+
fs-extra@^3.0.1:
2478+
version "3.0.1"
2479+
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-3.0.1.tgz#3794f378c58b342ea7dbbb23095109c4b3b62291"
2480+
dependencies:
2481+
graceful-fs "^4.1.2"
2482+
jsonfile "^3.0.0"
2483+
universalify "^0.1.0"
2484+
24772485
fs-readdir-recursive@^1.0.0:
24782486
version "1.0.0"
24792487
resolved "https://registry.yarnpkg.com/fs-readdir-recursive/-/fs-readdir-recursive-1.0.0.tgz#8cd1745c8b4f8a29c8caec392476921ba195f560"
@@ -2580,6 +2588,10 @@ gifsicle@^3.0.0:
25802588
bin-wrapper "^3.0.0"
25812589
logalot "^2.0.0"
25822590

2591+
git-revision-webpack-plugin@^2.5.1:
2592+
version "2.5.1"
2593+
resolved "https://registry.yarnpkg.com/git-revision-webpack-plugin/-/git-revision-webpack-plugin-2.5.1.tgz#3fb4398f376cf27678d6de96ba2669b518645e78"
2594+
25832595
glob-base@^0.3.0:
25842596
version "0.3.0"
25852597
resolved "https://registry.yarnpkg.com/glob-base/-/glob-base-0.3.0.tgz#dbb164f6221b1c0b1ccf82aea328b497df0ea3c4"
@@ -3591,6 +3603,12 @@ jsonfile@^2.1.0:
35913603
optionalDependencies:
35923604
graceful-fs "^4.1.6"
35933605

3606+
jsonfile@^3.0.0:
3607+
version "3.0.1"
3608+
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-3.0.1.tgz#a5ecc6f65f53f662c4415c7675a0331d0992ec66"
3609+
optionalDependencies:
3610+
graceful-fs "^4.1.6"
3611+
35943612
jsonify@~0.0.0:
35953613
version "0.0.0"
35963614
resolved "https://registry.yarnpkg.com/jsonify/-/jsonify-0.0.0.tgz#2c74b6ee41d93ca51b7b5aaee8f503631d252a73"
@@ -6181,6 +6199,10 @@ unique-stream@^2.0.2:
61816199
json-stable-stringify "^1.0.0"
61826200
through2-filter "^2.0.0"
61836201

6202+
universalify@^0.1.0:
6203+
version "0.1.0"
6204+
resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.0.tgz#9eb1c4651debcc670cc94f1a75762332bb967778"
6205+
61846206
unpipe@~1.0.0:
61856207
version "1.0.0"
61866208
resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec"

0 commit comments

Comments
 (0)