Skip to content

Commit 1e77943

Browse files
committed
Browser sync configuration update
1 parent 6029a45 commit 1e77943

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

config.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"PHP_BIN": "C:/Users/Saro/Desktop/Applicazioni PHP Desktop/phpapp/php74/php.exe",
3+
"PHP_INI_PATH": "C:/Users/Saro/Desktop/Applicazioni PHP Desktop/phpapp/php74/php.ini",
4+
"PORT": 8000
5+
}

start-dev.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
const path = require('path');
2+
const fs = require('fs');
3+
const concurrently = require('concurrently');
4+
5+
const configPath = path.resolve(__dirname, 'config.json');
6+
7+
if (!fs.existsSync(configPath)) {
8+
console.error('File config.json non trovato!');
9+
process.exit(1);
10+
}
11+
12+
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
13+
const {PHP_BIN, PHP_INI_PATH, PORT} = config;
14+
15+
if (!PHP_BIN || !PHP_INI_PATH || !PORT) {
16+
console.error('Variabili mancanti in config.json');
17+
process.exit(1);
18+
}
19+
20+
const phpCmd = `"${PHP_BIN}" -c "${PHP_INI_PATH}" -S localhost:${PORT} route.php`;
21+
// const bsCmd = `npx browser-sync start --proxy "localhost:${PORT}" --files "public/**/*" "src/**/*" --no-ui --no-open`;
22+
// const bsCmd = `npx browser-sync start --proxy "localhost:${PORT}" --files "**/*" --no-ui --open`;
23+
const bsCmd = `npx browser-sync start --config .bs-config.js`;
24+
25+
concurrently([
26+
{command: phpCmd, name: 'php', prefixColor: 'blue'},
27+
{command: bsCmd, name: 'bs', prefixColor: 'magenta'}
28+
], {
29+
killOthers: ['failure', 'success'],
30+
restartTries: 0
31+
}).result.then(() => {
32+
console.log('Tutti i processi terminati con successo');
33+
}).catch(err => {
34+
console.error('Errore in uno dei processi:', err);
35+
});

0 commit comments

Comments
 (0)