Skip to content

Commit ab4bc85

Browse files
committed
fix!: Make publicDir and modulesDir relative to project root (#1216)
1 parent defd796 commit ab4bc85

File tree

9 files changed

+11
-7
lines changed

9 files changed

+11
-7
lines changed

Diff for: docs/guide/essentials/assets.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ img.src = imageUrl;
2929

3030
## `/public` Directory
3131

32-
Files inside `<srcDir>/public/` are copied into the output folder as-is, without being processed by WXT's bundler.
32+
Files inside `<rootDir>/public/` are copied into the output folder as-is, without being processed by WXT's bundler.
3333

3434
Here's how you access them:
3535

@@ -54,6 +54,10 @@ img.src = imageUrl;
5454

5555
:::
5656

57+
:::warning
58+
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).
59+
:::
60+
5761
## Inside Content Scripts
5862

5963
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.

Diff for: docs/guide/essentials/project-structure.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@ After enabling it, your project structure should look like this:
6161
📂 {rootDir}/
6262
📁 .output/
6363
📁 .wxt/
64+
📁 modules/
65+
📁 public/
6466
📂 src/
6567
📁 assets/
6668
📁 components/
6769
📁 composables/
6870
📁 entrypoints/
6971
📁 hooks/
70-
📁 modules/
71-
📁 public/
7272
📁 utils/
7373
📄 app.config.ts
7474
📄 .env

Diff for: packages/i18n/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ However, it does have one major downside:
4949
helloWorld: Hello world!
5050
```
5151
52-
> `@wxt-dev/i18n` supports the standard messages format, so if you already have localization files at `<srcDir>/public/_locale/<lang>/messages.json`, you don't need to convert them to YAML or refactor them - just move them to `<srcDir>/locales/<lang>.json` and they'll just work out of the box!
52+
> `@wxt-dev/i18n` supports the standard messages format, so if you already have localization files at `<rootDir>/public/_locale/<lang>/messages.json`, you don't need to convert them to YAML or refactor them - just move them to `<srcDir>/locales/<lang>.json` and they'll just work out of the box!
5353

5454
4. To get a translation, use the auto-imported `i18n` object or import it manually:
5555

File renamed without changes.
File renamed without changes.
File renamed without changes.

Diff for: packages/wxt/src/core/resolve-config.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,14 @@ export async function resolveConfig(
8888
srcDir,
8989
mergedConfig.entrypointsDir ?? 'entrypoints',
9090
);
91-
const modulesDir = path.resolve(srcDir, mergedConfig.modulesDir ?? 'modules');
9291
if (await isDirMissing(entrypointsDir)) {
9392
logMissingDir(logger, 'Entrypoints', entrypointsDir);
9493
}
94+
const modulesDir = path.resolve(root, mergedConfig.modulesDir ?? 'modules');
9595
const filterEntrypoints = mergedConfig.filterEntrypoints?.length
9696
? new Set(mergedConfig.filterEntrypoints)
9797
: undefined;
98-
const publicDir = path.resolve(srcDir, mergedConfig.publicDir ?? 'public');
98+
const publicDir = path.resolve(root, mergedConfig.publicDir ?? 'public');
9999
const typesDir = path.resolve(wxtDir, 'types');
100100
const outBaseDir = path.resolve(root, mergedConfig.outDir ?? '.output');
101101
const modeSuffixes: Record<string, string | undefined> = {

Diff for: packages/wxt/src/types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export interface InlineConfig {
3838
*/
3939
entrypointsDir?: string;
4040
/**
41-
* @default "${config.srcDir}/modules"
41+
* @default "${config.root}/modules"
4242
*/
4343
modulesDir?: string;
4444
/**

0 commit comments

Comments
 (0)