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.tsHere'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 source code for your project's composable functions for Vueentrypoints/: Contains all the entrypoints that get bundled into your extensionhooks/: Auto-imported by default, contains source code for your project's hooks for React and Solidmodules/: Contains local WXT Modules for your projectpublic/: 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
export default defineConfig({
srcDir: 'src',
});After enabling it, your project structure should look like this:
html
📂 {rootDir}/
📁 .output/
📁 .wxt/
📁 modules/
📁 public/
📂 src/
📁 assets/
📁 components/
📁 composables/
📁 entrypoints/
📁 hooks/
📁 utils/
📄 app.config.ts
📄 .env
📄 .env.publish
📄 package.json
📄 tsconfig.json
📄 web-ext.config.ts
📄 wxt.config.tsCustomizing Other Directories
You can configure the following directories:
ts
export default defineConfig({
// Relative to project root
srcDir: "src", // default: "."
modulesDir: "wxt-modules", // default: "modules"
outDir: "dist", // default: ".output"
publicDir: "static", // default: "public"
// Relative to srcDir
entrypointsDir: "entries", // default: "entrypoints"
})You can use absolute or relative paths.