Skip to content

Commit a5a6ea0

Browse files
committed
fix: fixed vite builds!
styles fixed by disabling vite server CSP
1 parent b9978e3 commit a5a6ea0

File tree

7 files changed

+25
-22
lines changed

7 files changed

+25
-22
lines changed

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ endif
1414
build: install static/logo.png static/logo.svg
1515
npm run build ${androidflag}
1616

17+
vite-build:
18+
npx vite build
19+
20+
vite-dev:
21+
npx vite
22+
1723
static/logo.%: media/logo/logo.%
1824
@mkdir -p static
1925
cp $< $@

index.html

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@
88
<!-- Verify with https://csp-evaluator.withgoogle.com/ -->
99
<!-- TODO: fix CSP (should depend on prod/dev mode, as pre-vite )-->
1010
<meta http-equiv="Content-Security-Policy" content="default-src 'self' *:5666 ws://*:27180 https://api.github.com/repos/ActivityWatch/activitywatch/releases/latest; img-src 'self' data:; font-src 'self' data:; style-src 'self' 'unsafe-inline'; object-src 'none'; script-src 'self' 'unsafe-eval'">
11-
<!-- TODO: is this really the way? imports in main.js doesn't seem to work -->
12-
<link rel="stylesheet" href="/node_modules/bootstrap/dist/css/bootstrap.css">
13-
<link rel="stylesheet" href="/node_modules/bootstrap-vue/dist/bootstrap-vue.css">
14-
<link rel="stylesheet" href="/src/style/style.scss">
1511
</head>
1612
<body>
1713
<noscript>

src/components/CategoryEditTree.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,6 @@ export default {
9797
<style scoped lang="scss">
9898
.row.class:hover {
9999
background-color: #eee;
100-
boder-radius: 5px;
100+
border-radius: 5px;
101101
}
102102
</style>

src/main.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Vue.component('datetime', Datetime);
1616
// Load the Varela Round font
1717
import 'typeface-varela-round';
1818

19+
// Load the main style
1920
import './style/style.scss';
2021

2122
// Loads all the filters

src/visualizations/CategoryTree.vue

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ div(style="font-size: 0.9em")
3636
import 'vue-awesome/icons/circle';
3737
import 'vue-awesome/icons/regular/plus-square';
3838
import 'vue-awesome/icons/regular/minus-square';
39-
const _ = require('lodash');
40-
const classes = require('~/util/classes.ts');
39+
import _ from 'lodash';
40+
import { build_category_hierarchy, flatten_category_hierarchy } from '../util/classes.ts';
41+
import { IEvent } from '../util/interfaces.ts';
4142
4243
function _get_child_cats(cat, all_cats) {
4344
return _.filter(all_cats, c => _.isEqual(c.parent, cat.name));
@@ -75,16 +76,16 @@ export default {
7576
},
7677
category_hierarchy: function () {
7778
if (!this.events) return [];
78-
const events = JSON.parse(JSON.stringify(this.events));
79+
const events: IEvent[] = JSON.parse(JSON.stringify(this.events)) as IEvent[];
7980
80-
const hier = classes.build_category_hierarchy(
81+
const hier = build_category_hierarchy(
8182
_.map(events, e => {
82-
return { name: e.data['$category'] };
83+
return { name: e.data['$category'], rule: { type: 'none' } };
8384
})
8485
);
8586
86-
let cats = classes.flatten_category_hierarchy(hier).map(c => {
87-
c.duration = _.sumBy(
87+
let cats = flatten_category_hierarchy(hier).map(c => {
88+
c['duration'] = _.sumBy(
8889
events.filter(e => {
8990
const pcat = e.data['$category'].slice(0, c.name.length);
9091
return _.isEqual(c.name, pcat);
@@ -96,7 +97,7 @@ export default {
9697
9798
const cats_with_depth0 = _.sortBy(
9899
_.filter(cats, c => c.depth == 0),
99-
c => -c.duration
100+
c => -c['duration']
100101
);
101102
_.map(cats_with_depth0, c => _assign_children(c, cats));
102103

src/visualizations/periodusage.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
'use strict';
1+
import * as d3 from 'd3';
2+
import _ from 'lodash';
3+
import moment from 'moment';
24

3-
const d3 = require('d3');
4-
const _ = require('lodash');
5-
const moment = require('moment');
6-
7-
import { seconds_to_duration, get_hour_offset } from '../util/time';
5+
import { seconds_to_duration, get_hour_offset } from '../util/time.ts';
86

97
function create(svg_elem) {
108
// Clear element

vite.config.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ export default defineConfig(({ mode }) => {
88
return {
99
server: {
1010
port: 27180,
11-
headers: {
12-
'Content-Security-Policy': PRODUCTION ? "default-src 'self'" : "default-src 'self' *:5666",
13-
},
11+
// This breaks a bunch of style-related stuff (at least):
12+
//headers: {
13+
// 'Content-Security-Policy': PRODUCTION ? "default-src 'self'" : "default-src 'self' *:5666",
14+
//},
1415
},
1516
plugins: [vue()],
1617
publicDir: './static',

0 commit comments

Comments
 (0)