Skip to content

Commit

Permalink
[#1] Initial Vite & Craft Plugin config
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuapease committed May 14, 2024
1 parent ea5c7b5 commit 6789ba8
Show file tree
Hide file tree
Showing 15 changed files with 955 additions and 190 deletions.
11 changes: 11 additions & 0 deletions .ddev/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ use_dns_when_possible: true
composer_version: "2"
web_environment: []
nodejs_version: "18"
web_extra_exposed_ports:
# Expose ports for vite
- name: vite
container_port: 3000
http_port: 3000
https_port: 3001
web_extra_daemons:
# Run vite in a separate process
- name: 'vite'
command: 'npm install && npm run dev'
directory: /var/www/html

# Key features of ddev's config.yaml:

Expand Down
24 changes: 24 additions & 0 deletions config/vite.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

use craft\helpers\App;


// Decide which port to use for devServerPublic. This allows
// you to visit the http or https port. If you plant to only
// use http, make sure that PRIMARY_SITE_URL is set to http

$host = Craft::$app->getRequest()->getIsConsoleRequest()
? App::env('PRIMARY_SITE_URL')
: Craft::$app->getRequest()->getHostInfo();

// Match ports in .ddev/config.yaml -> web_extra_exposed_ports
$httpPort = 3000;
$httpsPort = 3001;
$devServerPort = str_starts_with($host, 'https') ? $httpsPort : $httpPort;

return [
'devServerPublic' => "$host:$devServerPort",
'serverPublic' => '/dist/',
'useDevServer' => App::env('CRAFT_ENVIRONMENT') === 'dev',
'manifestPath' => '@webroot/dist/.vite/manifest.json',
];
Loading

0 comments on commit 6789ba8

Please sign in to comment.