This repository provides a starter template for WordPress theme development using modern tools like Vite and TypeScript, integrated with wp-env
for a seamless local development environment.
- Vite: A fast and modern build tool for frontend development.
- TypeScript: Type-safe development for scalable and maintainable code.
- SASS: Efficient styling with support for glob imports.
- Live Reload: Real-time updates during development.
- Static Copy Plugin: Automates copying static assets during the build process.
- wp-env: A Docker-based WordPress local development environment.
Ensure the following are installed on your system:
-
Clone the repository:
git clone https://github.com/your-repo/wp-env-starter.git cd wp-env-starter
-
Install dependencies:
npm install # or yarn install
-
Start the development environment:
npm run wp-env start
This command sets up a WordPress environment using
wp-env
. -
Run the development server:
npm run dev
The Vite development server will start, providing live reloading and other modern development features.
-
Build the project for production:
npm run build
This will output optimized assets in the
dist
directory. -
Preview the production build:
npm run preview
This command previews the production build locally.
The package.json
includes the following scripts:
dev
: Start the Vite development server.build
: Compile TypeScript and build assets with Vite.preview
: Preview the production build.wp-env
: Manage the WordPress local development environment.
Customize the .wp-env.json
file to configure the WordPress environment. Example:
{
"core": "https://ja.wordpress.org/latest-ja.zip",
"plugins": ["https://downloads.wordpress.org/plugin/all-in-one-wp-migration.7.84.zip"]
}
Modify vite.config.ts
to customize the build process, plugins, or other configurations.
- Ensure Docker is running before starting the
wp-env
environment. - Check for correct Node.js and npm versions if you encounter dependency errors.
- Refer to the wp-env documentation for environment-specific issues.
This project is licensed under the MIT License.
Feel free to open issues or submit pull requests to enhance this template. Contributions are welcome!
Happy Coding!