Skip to content

Commit

Permalink
fix: more progress on vite builds
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikBjare committed May 3, 2024
1 parent cc82b3d commit b9978e3
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 17 deletions.
7 changes: 6 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@
<link rel="icon" type="image/png" href="/static/logo.png">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<!-- Verify with https://csp-evaluator.withgoogle.com/ -->
<meta http-equiv="Content-Security-Policy" content="default-src 'self' <%= htmlWebpackPlugin.options.templateParameters.cspDefaultSrc %> 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'">
<!-- TODO: fix CSP (should depend on prod/dev mode, as pre-vite )-->
<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'">
<!-- TODO: is this really the way? imports in main.js doesn't seem to work -->
<link rel="stylesheet" href="/node_modules/bootstrap/dist/css/bootstrap.css">
<link rel="stylesheet" href="/node_modules/bootstrap-vue/dist/bootstrap-vue.css">
<link rel="stylesheet" href="/src/style/style.scss">
</head>
<body>
<noscript>
Expand Down
11 changes: 5 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"vue-awesome": "^3.5.1",
"vue-chartjs": "^4.1.0",
"vue-color": "^2.8.1",
"vue-d3-sunburst": "^1.9.0",
"vue-d3-sunburst": "git+https://github.com/ErikBjare/Vue.D3.sunburst.git#patch-1",
"vue-datetime": "^1.0.0-beta.13",
"vuedraggable": "^2.24.3",
"weekstart": "^1.0.1",
Expand Down
4 changes: 2 additions & 2 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import router from './route.js';
import pinia from './stores';

// Register Font Awesome icon component
Vue.component('icon', () => import('vue-awesome/components/Icon'));
Vue.component('icon', () => import('vue-awesome/components/Icon.vue'));

// General components
Vue.component('error-boundary', () => import('./components/ErrorBoundary.vue'));
Expand Down Expand Up @@ -80,7 +80,7 @@ import { createClient, getClient, configureClient } from './util/awclient';
createClient();

// Setup Vue app
import App from './App';
import App from './App.vue';
new Vue({
el: '#app',
router: router,
Expand Down
2 changes: 1 addition & 1 deletion src/util/timeperiod.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import moment from 'moment';
import { get_day_start_with_offset } from '~/util/time';
import { get_day_start_with_offset } from './time';
import { useSettingsStore } from '~/stores/settings';

export interface TimePeriod {
Expand Down
28 changes: 22 additions & 6 deletions vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,26 @@ import path from 'node:path';
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue2';

export default defineConfig({
plugins: [vue()],
publicDir: './static',
resolve: {
alias: { '/src': path.resolve(process.cwd(), 'src') },
},
export default defineConfig(({ mode }) => {
const PRODUCTION = mode === 'production';

return {
server: {
port: 27180,
headers: {
'Content-Security-Policy': PRODUCTION ? "default-src 'self'" : "default-src 'self' *:5666",
},
},
plugins: [vue()],
publicDir: './static',
resolve: {
alias: { '~': path.resolve(__dirname, 'src') },
},
define: {
PRODUCTION,
AW_SERVER_URL: process.env.AW_SERVER_URL,
COMMIT_HASH: process.env.COMMIT_HASH,
'process.env.VUE_APP_ON_ANDROID': process.env.VUE_APP_ON_ANDROID,
},
};
});

0 comments on commit b9978e3

Please sign in to comment.