1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2025-02-22 22:37:37 +01:00
Maicol Battistini 2d37c8eda4
feat: Sostituito Laravel Mix con Vite
Vite permette di utilizzare i moduli ES6, in modo da caricare le views dei moduli custom tramite Import Maps (automatico). Gli assets devono essere inseriti nella cartella resources/static invece che nella cartella public.
Altri miglioramenti:
- I componenti sono stati migliorati, in modo da utilizzare collect.js (le collections di Laravel in JS) e classnames (per l'aggiunta di classi CSS ai componenti)
- Ogni cartella ha ora un file `index.js` così da poter importare facilmente i componenti nei moduli custom
- Possibilità di aggiungere un titolo nella pagina, definendolo nella route
-
2021-09-07 13:28:20 +02:00

127 lines
4.5 KiB
PHP

<?php
/**
* List all the directories under a directory.
*
* @param string $dir Parent directory
* @param false $include_parent Include parent directory in the returned array
* @param bool $relative Use relative paths instead of absolute ones
* @source https://www.php.net/manual/en/function.glob.php#82182
*/
function listdirs(string $dir, bool $include_parent = false, bool $relative = true): array
{
$dirs = $include_parent ? [$dir] : [];
$next = 0;
while (true) {
$glob = glob($dir.'/*', GLOB_ONLYDIR);
if (count($glob) > 0) {
foreach ($glob as $_dir) {
$dirs[] = $_dir;
}
} else {
break;
}
$dir = $dirs[$next++];
}
return $relative ? array_unique(array_map(static fn ($dir) => ltrim(str_replace(base_path(), '', $dir), DIRECTORY_SEPARATOR), $dirs)) : $dirs;
}
return [
/*
|--------------------------------------------------------------------------
| Entrypoints
|--------------------------------------------------------------------------
| The files in the configured directories will be considered
| entry points and will not be required in the configuration file.
| To disable the feature, set to false.
*/
'entrypoints' => array_merge(
listdirs(resource_path('js'), true),
[resource_path('scss/app.scss')] // listdirs(resource_path('scss'), true)
),
'ignore_patterns' => ['/\\.d\\.ts$/'],
/*
|--------------------------------------------------------------------------
| Aliases
|--------------------------------------------------------------------------
| These aliases will be added to the Vite configuration and used
| to generate a proper tsconfig.json file.
*/
'aliases' => [
'@' => 'resources',
],
/*
|--------------------------------------------------------------------------
| Static assets path
|--------------------------------------------------------------------------
| This option defines the directory that Vite considers as the
| public directory. Its content will be copied to the build directory
| at build-time.
| https://vitejs.dev/config/#publicdir
*/
'public_directory' => resource_path('static'),
/*
|--------------------------------------------------------------------------
| Ping timeout
|--------------------------------------------------------------------------
| The maximum duration, in seconds, that the ping to the development
| server should take while trying to determine whether to use the
| manifest or the server in a local environment. Using false will disable
| the feature.
| https://laravel-vite.innocenzi.dev/guide/configuration.html#ping-timeout
*/
'ping_timeout' => .5,
/*
|--------------------------------------------------------------------------
| Build path
|--------------------------------------------------------------------------
| The directory, relative to /public, in which Vite will build
| the production files. This should match "build.outDir" in the Vite
| configuration file.
*/
'build_path' => 'build',
/*
|--------------------------------------------------------------------------
| Development URL
|--------------------------------------------------------------------------
| The URL at which the Vite development server runs.
| This is used to generate the script tags when developing.
*/
'dev_url' => 'http://localhost:3000',
/*
|--------------------------------------------------------------------------
| Inject asset-fixing plugin
|--------------------------------------------------------------------------
| Currently, Vite does not support loading assets from an URL other than
| the development server's URL. If this option is enabled, a plugin fixing
| this issue will be injected.
| See: https://github.com/innocenzi/laravel-vite/issues/31
*/
'asset_plugin' => [
'find_regex' => '/\/resources\/(.*)\.(svg|jp?g|png|webp)/',
'replace_with' => '/resources/$1.$2',
],
/*
|--------------------------------------------------------------------------
| Commands
|--------------------------------------------------------------------------
| Defines the list of artisan commands that will be executed when
| the development server starts.
*/
'commands' => [
'vite:aliases',
// 'typescript:generate'
],
];