diff --git a/src/views/Home.vue b/src/views/Home.vue index c28b845..1b9e781 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -43,8 +43,12 @@ export default { href: `https://github.com/lbwa/vue-auth-boilerplate/releases/v${__VERSION__}` }, commit: { - label: __COMMIT_HASH__.slice(0, 15), - href: `https://github.com/lbwa/vue-auth-boilerplate/commit/${__COMMIT_HASH__}` + label: __COMMIT_HASH__ + ? __COMMIT_HASH__.slice(0, 15) + : 'Not a git repository', + href: __COMMIT_HASH__ + ? `https://github.com/lbwa/vue-auth-boilerplate/commit/${__COMMIT_HASH__}` + : '' }, latestBuild: new Date(__BUILD_TIME__).toLocaleString() }) diff --git a/vue.config.js b/vue.config.js index 94d4c18..1a9c1dd 100644 --- a/vue.config.js +++ b/vue.config.js @@ -10,18 +10,23 @@ module.exports = { chainWebpack(config) { /** - * Feature flags + * Feature flags in **compiler** time * @doc https://webpack.js.org/plugins/define-plugin/#feature-flags */ config.plugin('define').tap(([args]) => { args.__DEV__ = JSON.stringify(__DEV__) args.__BUILD_TIME__ = JSON.stringify(new Date().toString()) args.__VERSION__ = JSON.stringify(require('./package.json').version) - args.__COMMIT_HASH__ = JSON.stringify( - require('child_process') - .execSync('git rev-parse HEAD') - .toString() - ) + try { + args.__COMMIT_HASH__ = JSON.stringify( + require('child_process') + .execSync('git rev-parse HEAD') + .toString() + ) + } catch (err) { + // works without git + args.__COMMIT_HASH__ = JSON.stringify('') + } return [args] })