fix!: Make publicDir and modulesDir relative to project root (#1216)
This commit is contained in:
@@ -46,7 +46,7 @@ import image from '~/assets/image.png';
|
||||
|
||||
## `/public` Directory
|
||||
|
||||
Files inside `<srcDir>/public/` are copied into the output folder as-is, without being processed by WXT's bundler.
|
||||
Files inside `<rootDir>/public/` are copied into the output folder as-is, without being processed by WXT's bundler.
|
||||
|
||||
Here's how you access them:
|
||||
|
||||
@@ -81,6 +81,10 @@ img.src = imageUrl;
|
||||
|
||||
:::
|
||||
|
||||
:::warning
|
||||
Assets in the `public/` directory are **_not_** accessible in content scripts by default. To use a public asset in a content script, you must add it to your manifest's [`web_accessible_resources` array](/api/reference/wxt/type-aliases/UserManifest#web-accessible-resources).
|
||||
:::
|
||||
|
||||
## Inside Content Scripts
|
||||
|
||||
Assets inside content scripts are a little different. By default, when you import an asset, it returns just the path to the asset. This is because Vite assumes you're loading assets from the same hostname.
|
||||
|
||||
@@ -60,14 +60,14 @@ After enabling it, your project structure should look like this:
|
||||
📂 {rootDir}/
|
||||
📁 .output/
|
||||
📁 .wxt/
|
||||
📁 modules/
|
||||
📁 public/
|
||||
📂 src/
|
||||
📁 assets/
|
||||
📁 components/
|
||||
📁 composables/
|
||||
📁 entrypoints/
|
||||
📁 hooks/
|
||||
📁 modules/
|
||||
📁 public/
|
||||
📁 utils/
|
||||
📄 app.config.ts
|
||||
📄 .env
|
||||
|
||||
@@ -89,14 +89,14 @@ export async function resolveConfig(
|
||||
srcDir,
|
||||
mergedConfig.entrypointsDir ?? 'entrypoints',
|
||||
);
|
||||
const modulesDir = path.resolve(srcDir, mergedConfig.modulesDir ?? 'modules');
|
||||
if (await isDirMissing(entrypointsDir)) {
|
||||
logMissingDir(logger, 'Entrypoints', entrypointsDir);
|
||||
}
|
||||
const modulesDir = path.resolve(root, mergedConfig.modulesDir ?? 'modules');
|
||||
const filterEntrypoints = mergedConfig.filterEntrypoints?.length
|
||||
? new Set(mergedConfig.filterEntrypoints)
|
||||
: undefined;
|
||||
const publicDir = path.resolve(srcDir, mergedConfig.publicDir ?? 'public');
|
||||
const publicDir = path.resolve(root, mergedConfig.publicDir ?? 'public');
|
||||
const typesDir = path.resolve(wxtDir, 'types');
|
||||
const outBaseDir = path.resolve(root, mergedConfig.outDir ?? '.output');
|
||||
const modeSuffixes: Record<string, string | undefined> = {
|
||||
|
||||
@@ -38,7 +38,7 @@ export interface InlineConfig {
|
||||
*/
|
||||
entrypointsDir?: string;
|
||||
/**
|
||||
* @default "${config.srcDir}/modules"
|
||||
* @default "${config.root}/modules"
|
||||
*/
|
||||
modulesDir?: string;
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user