Project Structure
WXT follows a strict project structure. By default, it's a flat folder structure that looks like this:
html
📂 {rootDir}/
📁 .output/
📁 .wxt/
📁 assets/
📁 components/
📁 composables/
📁 entrypoints/
📁 hooks/
📁 modules/
📁 public/
📁 utils/
📄 .env
📄 .env.publish
📄 app.config.ts
📄 package.json
📄 tsconfig.json
📄 web-ext.config.ts
📄 wxt.config.ts
Here's a brief summary of each of these files and directories:
.output/
: All build artifacts will go here.wxt/
: Generated by WXT, it contains TS configassets/
: Contains all CSS, images, and other assets that should be processed by WXTcomponents/
: Auto-imported by default, contains UI componentscomposables/
: Auto-imported by default, contains composable functions for Vueentrypoints/
: Contains all the entrypoints that get bundled into your extensionhooks/
: Auto-imported by default, contains hooks for React and Solidpublic/
: Contains any files you want to copy into the output folder as-is, without being processed by WXTutils/
: Auto-imported by default, contains generic utilities used throughout your project.env
: Contains Environment Variables.env.publish
: Contains Environment Variables for publishingapp.config.ts
: Contains Runtime Configpackage.json
: The standard file used by your package managertsconfig.json
: Config telling TypeScript how to behaveweb-ext.config.ts
: Configure Browser Startupwxt.config.ts
: The main config file for WXT projects
Adding a src/
Directory
Many developers like having a src/
directory to separate source code from configuration files. You can enable it inside the wxt.config.ts
file:
ts
// wxt.config.ts
export default defineConfig({
srcDir: 'src',
});
After enabling it, your project structure should look like this:
html
📂 {rootDir}/
📁 .output/
📁 .wxt/
📂 src/
📁 assets/
📁 components/
📁 composables/
📁 entrypoints/
📁 hooks/
📁 modules/
📁 public/
📁 utils/
📄 app.config.ts
📄 .env
📄 .env.publish
📄 package.json
📄 tsconfig.json
📄 web-ext.config.ts
📄 wxt.config.ts
Customizing Other Directories
You can configure the following directories:
ts
// wxt.config.ts
export default defineConfig({
// Relative to project root
srcDir: "src", // default: "."
outDir: "dist", // default: ".output"
// Relative to srcDir
entrypointsDir: "entries", // default: "entrypoints"
modulesDir: "wxt-modules", // default: "modules"
publicDir: "static", // default: "public"
})
You can use absolute or relative paths.