Skip to content

Commit

Permalink
fix: windows dynamic import protocol issue (#268)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonghakseo authored Nov 11, 2023
1 parent 8007ec9 commit de514ed
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion utils/plugins/make-manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,26 @@ import * as path from 'path';
import colorLog from '../log';
import ManifestParser from '../manifest-parser';
import type { PluginOption } from 'vite';
import url from 'url';
import * as process from 'process';

const { resolve } = path;

const rootDir = resolve(__dirname, '..', '..');
const distDir = resolve(rootDir, 'dist');
const manifestFile = resolve(rootDir, 'manifest.js');

const getManifestWithCacheBurst = () => import(manifestFile + '?' + Date.now().toString());
const getManifestWithCacheBurst = (): Promise<{ default: chrome.runtime.ManifestV3 }> => {
const withCacheBurst = (path: string) => `${path}?${Date.now().toString()}`;
/**
* In Windows, import() doesn't work without file:// protocol.
* So, we need to convert path to file:// protocol. (url.pathToFileURL)
*/
if (process.platform === 'win32') {
return import(withCacheBurst(url.pathToFileURL(manifestFile).href));
}
return import(withCacheBurst(manifestFile));
};

export default function makeManifest(config: { contentScriptCssKey?: string }): PluginOption {
function makeManifest(manifest: chrome.runtime.ManifestV3, to: string) {
Expand Down

0 comments on commit de514ed

Please sign in to comment.