2021-12-30 15:12:03 +01:00
|
|
|
/* eslint-disable import/no-extraneous-dependencies */
|
2023-04-20 20:00:38 +02:00
|
|
|
import Inertia from 'inertia-plugin/vite';
|
|
|
|
import laravel from 'laravel-vite-plugin';
|
2023-05-01 15:24:03 +02:00
|
|
|
import * as fs from 'node:fs';
|
|
|
|
import * as path from 'node:path';
|
2022-03-02 20:20:20 +01:00
|
|
|
import {defineConfig} from 'vite';
|
2023-04-20 20:00:38 +02:00
|
|
|
import laravelTranslations from 'vite-plugin-laravel-translations';
|
|
|
|
import progress from 'vite-plugin-progress';
|
2022-01-06 17:19:59 +01:00
|
|
|
import {VitePWA} from 'vite-plugin-pwa';
|
2023-04-20 20:00:38 +02:00
|
|
|
import installedPackages from './vendor/composer/installed.json';
|
|
|
|
|
|
|
|
const modules = installedPackages.packages.filter((packageInfo) => packageInfo.type === 'openstamanager-module');
|
2023-05-01 15:24:03 +02:00
|
|
|
const bootstrapFiles = [];
|
|
|
|
for (const module of modules) {
|
|
|
|
const basePath = `./vendor/${module.name}/resources/ts/bootstrap`;
|
|
|
|
if (fs.existsSync(`${basePath}.ts`)) {
|
|
|
|
bootstrapFiles.push(`${basePath}.ts`);
|
|
|
|
} else if (fs.existsSync(`${basePath}.tsx`)) {
|
|
|
|
bootstrapFiles.push(`${basePath}.tsx`);
|
|
|
|
}
|
|
|
|
}
|
2023-04-20 20:00:38 +02:00
|
|
|
|
2021-09-07 13:28:20 +02:00
|
|
|
|
2023-04-20 20:00:38 +02:00
|
|
|
// noinspection JSUnusedGlobalSymbols
|
2022-10-28 19:50:15 +02:00
|
|
|
export default defineConfig({
|
2023-04-20 20:00:38 +02:00
|
|
|
assetsInclude: '**/*.xml',
|
2022-01-10 17:20:41 +01:00
|
|
|
build: {
|
2022-10-28 19:50:15 +02:00
|
|
|
minify: false,
|
2023-04-20 20:00:38 +02:00
|
|
|
target: 'esnext'
|
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
|
|
|
'~': '/resources/ts',
|
|
|
|
'@osm': '/resources/ts'
|
|
|
|
}
|
2022-01-10 17:20:41 +01:00
|
|
|
},
|
2022-10-28 19:50:15 +02:00
|
|
|
esbuild: {
|
|
|
|
jsx: 'transform',
|
|
|
|
jsxFactory: 'm',
|
|
|
|
jsxFragment: '\'[\'',
|
|
|
|
jsxInject: 'import m from \'mithril\''
|
2022-03-02 20:20:20 +01:00
|
|
|
},
|
|
|
|
plugins: [
|
2023-04-20 20:00:38 +02:00
|
|
|
laravel({
|
|
|
|
input: [
|
2023-05-01 15:24:03 +02:00
|
|
|
'resources/ts/app.ts',
|
|
|
|
...bootstrapFiles
|
2023-04-20 20:00:38 +02:00
|
|
|
],
|
|
|
|
refresh: true
|
|
|
|
}),
|
|
|
|
laravelTranslations({
|
|
|
|
namespace: 'osm',
|
|
|
|
includeJson: true
|
|
|
|
}),
|
|
|
|
// eslint-disable-next-line new-cap
|
|
|
|
Inertia({
|
|
|
|
namespaces: ({npm, composer}) => {
|
|
|
|
const namespaces = [];
|
|
|
|
for (const module of modules) {
|
|
|
|
// @ts-ignore
|
|
|
|
namespaces.push(composer(module.name));
|
|
|
|
}
|
|
|
|
return namespaces;
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
progress({
|
|
|
|
// eslint-disable-next-line unicorn/prefer-module
|
|
|
|
srcDir: path.resolve(__dirname, 'resources/ts')
|
|
|
|
}),
|
2022-03-02 20:20:20 +01:00
|
|
|
// eslint-disable-next-line new-cap
|
|
|
|
VitePWA({
|
2022-10-28 19:50:15 +02:00
|
|
|
// TODO: Check options
|
2022-03-02 20:20:20 +01:00
|
|
|
includeAssets: [
|
2023-04-20 20:00:38 +02:00
|
|
|
'resources/images/favicon/favicon.ico',
|
2022-03-02 20:20:20 +01:00
|
|
|
'../robots.txt',
|
2023-04-20 20:00:38 +02:00
|
|
|
'resources/images/favicon/apple-touch-icon.png',
|
|
|
|
'resources/images/*.png'
|
2022-03-02 20:20:20 +01:00
|
|
|
],
|
|
|
|
manifest: {
|
|
|
|
name: 'OpenSTAManager',
|
|
|
|
short_name: 'OSM',
|
|
|
|
description: 'Il software gestionale open source per l\'assistenza tecnica e la fatturazione',
|
|
|
|
categories: ['business', 'productivity'],
|
|
|
|
display: 'minimal-ui',
|
|
|
|
theme_color: '#3f3f3f',
|
|
|
|
background_color: '#fffff',
|
|
|
|
icons: [
|
|
|
|
{
|
|
|
|
src: 'android-chrome-192x192.png',
|
|
|
|
sizes: '192x192',
|
|
|
|
type: 'image/png'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
src: 'android-chrome-512x512.png',
|
|
|
|
sizes: '512x512',
|
|
|
|
type: 'image/png'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
src: 'android-chrome-512x512.png',
|
|
|
|
sizes: '512x512',
|
|
|
|
type: 'image/png',
|
|
|
|
purpose: 'any maskable'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
useCredentials: true
|
|
|
|
})
|
|
|
|
]
|
2022-10-28 19:50:15 +02:00
|
|
|
});
|