Skip to content

Commit 0f6cd31

Browse files
committed
Improve standalone build version text
1 parent 8fb758e commit 0f6cd31

File tree

4 files changed

+32
-11
lines changed

4 files changed

+32
-11
lines changed

src/build/version-loader.js

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/p4/P4.svelte

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
import Progress from './Progress.svelte';
1010
import Modals from './Modals.svelte';
1111
import {progress, theme} from './stores';
12-
import {isSupported, isSafari, isStandalone} from './environment';
13-
import version from '../build/version-loader!';
12+
import {isSupported, isSafari, isStandalone, version} from './environment';
1413
import {APP_NAME, FEEDBACK_PRIMARY, FEEDBACK_SECONDARY, ACCENT_COLOR, SOURCE_CODE, WEBSITE} from '../packager/brand';
1514
1615
let projectData;
@@ -108,6 +107,13 @@
108107
.disclaimer {
109108
font-style: italic;
110109
}
110+
.version {
111+
font-size: small;
112+
opacity: 0.8;
113+
}
114+
.version a {
115+
color: inherit;
116+
}
111117
</style>
112118

113119
<Modals bind:modalVisible={modalVisible} />
@@ -117,7 +123,12 @@
117123
<div>
118124
<h1>{APP_NAME}</h1>
119125
{#if version}
120-
<p><i>{version}</i> - <a href={WEBSITE}>Online version</a></p>
126+
<p class="version">
127+
{version}
128+
{#if isStandalone}
129+
- <a href={WEBSITE}>{WEBSITE}</a>
130+
{/if}
131+
</p>
121132
{/if}
122133
<p>{$_('p4.description1')}</p>
123134
<p>

src/p4/environment.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ export const isSupported = typeof TextDecoder === 'function';
44
export const isSafari = navigator.vendor === 'Apple Computer, Inc.';
55

66
export const isStandalone = !!process.env.STANDALONE;
7+
8+
export const version = process.env.VERSION;

webpack.config.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,21 @@ const base = {
1515
const dist = path.resolve(__dirname, 'dist');
1616
const buildId = isProduction ? require('./src/build/generate-scaffolding-build-id') : null;
1717

18+
const getVersion = () => {
19+
if (process.env.VERSION) {
20+
return process.env.VERSION;
21+
}
22+
if (isStandalone) {
23+
const now = new Date();
24+
const dateString = `${now.getFullYear()}-${(now.getMonth() + 1).toString().padStart(2, '0')}-${now.getDate().toString().padStart(2, '0')}`;
25+
const packageJSON = require('./package.json');
26+
const version = packageJSON.version;
27+
return `Standalone v${version} (${dateString})`;
28+
}
29+
return null;
30+
};
31+
const version = getVersion();
32+
1833
const makeScaffolding = ({full}) => ({
1934
...base,
2035
devtool: isProduction ? '' : 'source-map',
@@ -155,6 +170,7 @@ const makeWebsite = () => ({
155170
new webpack.DefinePlugin({
156171
'process.env.ENABLE_SERVICE_WORKER': JSON.stringify(process.env.ENABLE_SERVICE_WORKER),
157172
'process.env.STANDALONE': JSON.stringify(isStandalone ? true : false),
173+
'process.env.VERSION': JSON.stringify(version),
158174
'process.env.PLAUSIBLE_API': JSON.stringify(process.env.PLAUSIBLE_API),
159175
'process.env.PLAUSIBLE_DOMAIN': JSON.stringify(process.env.PLAUSIBLE_DOMAIN),
160176
}),

0 commit comments

Comments
 (0)