Skip to content

Commit

Permalink
[#1] Basic Vite setup (PR #4)
Browse files Browse the repository at this point in the history
* [#1] Require nystudio107/craft-vite:^5.0.0 package.

* [#1] Initial Vite & Craft Plugin config

* [#1] .gitignore Updates
  • Loading branch information
joshuapease authored May 14, 2024
1 parent cff431c commit bfd0c2c
Show file tree
Hide file tree
Showing 18 changed files with 1,084 additions and 191 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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
/.idea
/vendor
.DS_Store
node_modules
/web/dist
/.vite
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"prefer-stable": true,
"require": {
"craftcms/cms": "^5.0.0",
"nystudio107/craft-vite": "^5.0.0",
"vlucas/phpdotenv": "^5.4.0"
},
"require-dev": {
Expand Down
127 changes: 126 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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

use craft\helpers\App;


// Decides 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
//
// Match ports to .ddev/config.yaml -> web_extra_exposed_ports
$host = Craft::$app->getRequest()->getIsConsoleRequest()
? App::env('PRIMARY_SITE_URL')
: Craft::$app->getRequest()->getHostInfo();
$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 bfd0c2c

Please sign in to comment.