Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Make index.html be included with npm run watch (#541)

Leendert de Borstb1ef9589761f
diff --git a/browser-extensions/chrome/index.html b/browser-extensions/chrome/index.html
index 88aad5f8c..402ae07b7 100644
--- a/browser-extensions/chrome/index.html
+++ b/browser-extensions/chrome/index.html
@@ -7,6 +7,6 @@
</head>
<body>
<div id="root"></div>
- <script type="module" src="src/Index.tsx"></script>
+ <script type="module" src="src/app/Index.tsx"></script>
</body>
</html>
diff --git a/browser-extensions/chrome/package.json b/browser-extensions/chrome/package.json
index 46321a5cf..4abead150 100644
--- a/browser-extensions/chrome/package.json
+++ b/browser-extensions/chrome/package.json
@@ -5,14 +5,13 @@
"type": "module",
"scripts": {
"test": "vitest",
- "dev": "vite",
+ "dev": "vite dev",
"preview": "vite preview",
"lint": "eslint src",
"lint:custom": "eslint",
"lint:fix": "eslint src --fix",
"build": "vite build",
- "watch": "vite build --watch",
- "build:content-css": "tailwindcss -i ./src/contentScript/style.css -o ./dist/contentScript.css --config tailwind.content.config.js"
+ "watch": "vite build --watch --mode development"
},
"keywords": [],
"author": "",
diff --git a/browser-extensions/chrome/src/App.tsx b/browser-extensions/chrome/src/app/App.tsx
similarity index 80%
rename from browser-extensions/chrome/src/App.tsx
rename to browser-extensions/chrome/src/app/App.tsx
index 3545e7d5b..c78b05ca1 100644
--- a/browser-extensions/chrome/src/App.tsx
+++ b/browser-extensions/chrome/src/app/App.tsx
@@ -1,18 +1,18 @@
import React, { useState, useEffect } from 'react';
import { HashRouter as Router, Routes, Route } from 'react-router-dom';
-import { useAuth } from './app/context/AuthContext';
-import { useDb } from './app/context/DbContext';
-import { useMinDurationLoading } from './app/hooks/useMinDurationLoading';
-import Header from './app/components/Layout/Header';
-import BottomNav from './app/components/Layout/BottomNav';
-import Settings from './app/pages/Settings';
-import CredentialsList from './app/pages/CredentialsList';
-import EmailsList from './app/pages/EmailsList';
-import LoadingSpinner from './app/components/LoadingSpinner';
-import Home from './app/pages/Home';
-import './app/style.css';
-import CredentialDetails from './app/pages/CredentialDetails';
-import EmailDetails from './app/pages/EmailDetails';
+import { useAuth } from './context/AuthContext';
+import { useDb } from './context/DbContext';
+import { useMinDurationLoading } from './hooks/useMinDurationLoading';
+import Header from './components/Layout/Header';
+import BottomNav from './components/Layout/BottomNav';
+import Settings from './pages/Settings';
+import CredentialsList from './pages/CredentialsList';
+import EmailsList from './pages/EmailsList';
+import LoadingSpinner from './components/LoadingSpinner';
+import Home from './pages/Home';
+import './style.css';
+import CredentialDetails from './pages/CredentialDetails';
+import EmailDetails from './pages/EmailDetails';
/**
* Route configuration.
diff --git a/browser-extensions/chrome/src/index.tsx b/browser-extensions/chrome/src/app/Index.tsx
similarity index 59%
rename from browser-extensions/chrome/src/index.tsx
rename to browser-extensions/chrome/src/app/Index.tsx
index 4a0576587..de98515b1 100644
--- a/browser-extensions/chrome/src/index.tsx
+++ b/browser-extensions/chrome/src/app/Index.tsx
@@ -1,9 +1,9 @@
import ReactDOM from 'react-dom/client';
import App from './App';
-import { AuthProvider } from './app/context/AuthContext';
-import { WebApiProvider } from './app/context/WebApiContext';
-import { DbProvider } from './app/context/DbContext';
-import { LoadingProvider } from './app/context/LoadingContext';
+import { AuthProvider } from './context/AuthContext';
+import { WebApiProvider } from './context/WebApiContext';
+import { DbProvider } from './context/DbContext';
+import { LoadingProvider } from './context/LoadingContext';
const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement);
root.render(
diff --git a/browser-extensions/chrome/src/contentscript/Popup.ts b/browser-extensions/chrome/src/contentscript/Popup.ts
index d8112a866..29f003e20 100644
--- a/browser-extensions/chrome/src/contentscript/Popup.ts
+++ b/browser-extensions/chrome/src/contentscript/Popup.ts
@@ -110,11 +110,6 @@ export function updatePopupContent(credentials: Credential[], credentialList: HT
export function removeExistingPopup() : void {
const existing = document.getElementById('aliasvault-credential-popup');
if (existing) {
- /*
- * Remove the mousedown event listener before removing the popup
- * TODO: remove if not needed
- * document.removeEventListener('mousedown', handleClickOutside);
- */
existing.remove();
}
}
diff --git a/browser-extensions/chrome/vite-plugins/dictionary-loader.ts b/browser-extensions/chrome/vite-plugins/dictionary-loader.ts
index 860286963..d55a74145 100644
--- a/browser-extensions/chrome/vite-plugins/dictionary-loader.ts
+++ b/browser-extensions/chrome/vite-plugins/dictionary-loader.ts
@@ -13,13 +13,14 @@ export default function dictionaryLoader() {
return {
name: 'dictionary-loader',
transform(code: string, id: string) {
- // Only transform identity generator files
- // TODO: refactor to dynamically load all dictionaries for all languages
- // instead of hardcoding the languages here.
- if (id.includes('IdentityGeneratorEn.ts') || id.includes('IdentityGeneratorNl.ts')) {
- const lang = id.includes('IdentityGeneratorEn.ts') ? 'en' : 'nl';
- // Load dictionaries from the repository root 'dictionaries' folder. These dictionaries
- // are used by both .NET and JavaScript code.
+ // Check if file matches the expected IdentityGenerator filename pattern.
+ // This checks for filenames like IdentityGeneratorEn.ts or IdentityGeneratorNl.ts.
+ // To add support for other languages, add a new file with the language code that matches the dictionary file langauge code.
+ // E.g. for French, add IdentityGeneratorFr.ts and ensure the dictionary files are present in the '/dictionaries/fr' folder.
+ const match = id.match(/IdentityGenerator([A-Za-z]{2})\.ts$/);
+ if (match) {
+ const lang = match[1].toLowerCase(); // Extract language code and convert to lowercase
+ // Load dictionaries from the repository root 'dictionaries' folder
const dictionaryPath = path.resolve(__dirname, `../../../dictionaries/${lang}`);
try {
@@ -39,7 +40,7 @@ export default function dictionaryLoader() {
.filter(name => name.trim())
.map(name => name.trim());
- // Replace the placeholder strings with stringified arrays
+ // Update placeholder replacements to use dynamic language code
code = code.replace(
new RegExp(`['"\`]__FIRSTNAMES_MALE_${lang.toUpperCase()}__['"\`]`, 'g'),
`[${firstNamesMale.map(name => `"${name}"`).join(',')}]`
diff --git a/browser-extensions/chrome/vite.config.js b/browser-extensions/chrome/vite.config.js
index d77f696c4..d8e6b9135 100644
--- a/browser-extensions/chrome/vite.config.js
+++ b/browser-extensions/chrome/vite.config.js
@@ -43,10 +43,17 @@ export default defineConfig({
'@': '/src'
}
},
- server: {
- open: '/src/popup.html'
- },
build: {
- outDir: 'dist'
+ outDir: 'dist',
+ watch: {
+ include: ['src/**', 'manifest.json'],
+ }
+ },
+ server: {
+ watch: {
+ usePolling: true,
+ interval: 100,
+ ignored: ['!**/node_modules/**', '**/dist/**'],
+ }
}
});