Skip to content

Commit b78ad4f

Browse files
committed
fix: make files in ./static serve at root (harmonize webpack and vite)
1 parent 8b2d886 commit b78ad4f

File tree

4 files changed

+30
-16
lines changed

4 files changed

+30
-16
lines changed

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="utf-8">
55
<title>ActivityWatch</title>
6-
<link rel="icon" type="image/png" href="/static/logo.png">
6+
<link rel="icon" type="image/png" href="/logo.png">
77
<meta name="viewport" content="width=device-width,initial-scale=1.0">
88
<!-- Verify with https://csp-evaluator.withgoogle.com/ -->
99
<!-- TODO: fix CSP (should depend on prod/dev mode, as pre-vite )-->

src/App.vue

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ div#wrapper(v-if="loaded")
1515
<script lang="ts">
1616
import { useSettingsStore } from '~/stores/settings';
1717
import { useServerStore } from '~/stores/server';
18+
// if vite is used, you can import css file as module
19+
//import darkCssUrl from '../static/dark.css?url';
20+
//import darkCssContent from '../static/dark.css?inline';
1821
1922
export default {
2023
data: function () {
@@ -38,12 +41,23 @@ export default {
3841
const theme = settingsStore.theme;
3942
// Check Application Mode (Light | Dark)
4043
if (theme !== null && theme === 'dark') {
41-
// Create Dark Theme Element
42-
const themeLink = document.createElement('link');
43-
themeLink.href = '/static/dark.css';
44-
themeLink.rel = 'stylesheet';
45-
// Append Dark Theme Element If Selected Mode Is Dark
46-
theme === 'dark' ? document.querySelector('head').appendChild(themeLink) : '';
44+
const method: 'link' | 'style' = 'link';
45+
46+
if (method === 'link') {
47+
// Method 1: Create <link> Element
48+
// Create Dark Theme Element
49+
const themeLink = document.createElement('link');
50+
themeLink.href = '/dark.css'; // darkCssUrl
51+
themeLink.rel = 'stylesheet';
52+
// Append Dark Theme Element If Selected Mode Is Dark
53+
theme === 'dark' ? document.querySelector('head').appendChild(themeLink) : '';
54+
} else {
55+
// Not supported for Webpack due to not supporting ?inline import in a cross-compatible way (afaik)
56+
// Method 2: Create <style> Element
57+
//const style = document.createElement('style');
58+
//style.innerHTML = darkCssContent;
59+
//theme === 'dark' ? document.querySelector('head').appendChild(style) : '';
60+
}
4761
}
4862
this.loaded = true;
4963
},

src/components/Header.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ div(:class="{'fixed-top-padding': fixedTopMenu}")
44
// Brand on mobile
55
b-navbar-nav.d-block.d-lg-none
66
b-navbar-brand(to="/" style="background-color: transparent;")
7-
img.aligh-middle(src="/static/logo.png" style="height: 1.5em;")
7+
img.aligh-middle(src="/logo.png" style="height: 1.5em;")
88
span.ml-2.align-middle(style="font-size: 1em; color: #000;") ActivityWatch
99

1010
b-navbar-toggle(target="nav-collapse")
@@ -47,7 +47,7 @@ div(:class="{'fixed-top-padding': fixedTopMenu}")
4747
// Brand on large screens (centered)
4848
b-navbar-nav.abs-center.d-none.d-lg-block
4949
b-navbar-brand(to="/" style="background-color: transparent;")
50-
img.ml-0.aligh-middle(src="/static/logo.png" style="height: 1.5em;")
50+
img.ml-0.aligh-middle(src="/logo.png" style="height: 1.5em;")
5151
span.ml-2.align-middle(style="font-size: 1.0em; color: #000;") ActivityWatch
5252

5353
b-navbar-nav.ml-auto

vue.config.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export default {
4949
AW_SERVER_URL: process.env.AW_SERVER_URL,
5050
COMMIT_HASH: JSON.stringify(_COMMIT_HASH),
5151
}),
52-
new CopyWebpackPlugin([{ from: 'static/', to: 'static' }]),
52+
new CopyWebpackPlugin([{ from: 'static/', to: '' }]),
5353
],
5454
},
5555
devServer: {
@@ -63,16 +63,16 @@ export default {
6363
name: 'ActivityWatch',
6464
iconPaths: {
6565
faviconSVG: null, // SVG won't render without needed fonts etc, so fall back to png
66-
favicon32: 'static/logo.png',
67-
favicon16: 'static/logo.png',
68-
appleTouchIcon: 'static/logo.png',
69-
//maskIcon: 'static/logo.png',
70-
msTileImage: 'static/logo.png',
66+
favicon32: 'logo.png',
67+
favicon16: 'logo.png',
68+
appleTouchIcon: 'logo.png',
69+
//maskIcon: 'logo.png',
70+
msTileImage: 'logo.png',
7171
},
7272
manifestOptions: {
7373
icons: [
7474
{
75-
src: 'static/logo.png',
75+
src: 'logo.png',
7676
sizes: '512x512',
7777
type: 'image/png',
7878
},

0 commit comments

Comments
 (0)