Skip to content

Commit d3b14af

Browse files
committed
chore: Extract helper function
1 parent ba2197a commit d3b14af

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/core/create-server.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ import pc from 'picocolors';
2626
import { relative } from 'node:path';
2727
import { registerWxt, wxt } from './wxt';
2828
import { unnormalizePath } from './utils/paths';
29-
import { mapWxtOptionsToRegisteredContentScript } from './utils/content-scripts';
29+
import {
30+
getContentScriptJs,
31+
mapWxtOptionsToRegisteredContentScript,
32+
} from './utils/content-scripts';
3033

3134
/**
3235
* Creates a dev server and pre-builds all the files that need to exist before loading the extension.
@@ -232,7 +235,7 @@ function reloadContentScripts(steps: BuildStepOutput[], server: WxtDevServer) {
232235
const entry = step.entrypoints;
233236
if (Array.isArray(entry) || entry.type !== 'content-script') return;
234237

235-
const js = [getEntrypointBundlePath(entry, wxt.config.outDir, '.js')];
238+
const js = getContentScriptJs(wxt.config, entry);
236239
const cssMap = getContentScriptsCssMap(server.currentOutput, [entry]);
237240
const css = getContentScriptCssFiles([entry], cssMap);
238241

src/core/utils/content-scripts.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { Manifest, Scripting } from '~/browser';
2-
import { ContentScriptEntrypoint } from '~/types';
2+
import { ContentScriptEntrypoint, ResolvedConfig } from '~/types';
3+
import { getEntrypointBundlePath } from './entrypoints';
34

45
/**
56
* Returns a unique and consistent string hash based on a content scripts options.
@@ -83,3 +84,10 @@ export function mapWxtOptionsToRegisteredContentScript(
8384
world: options.world,
8485
};
8586
}
87+
88+
export function getContentScriptJs(
89+
config: ResolvedConfig,
90+
entrypoint: ContentScriptEntrypoint,
91+
): string[] {
92+
return [getEntrypointBundlePath(entrypoint, config.outDir, '.js')];
93+
}

0 commit comments

Comments
 (0)