Aggiungi DefinePlugin per la gestione dell'ambiente e aggiorna gli URL API per la produzione

This commit is contained in:
2026-05-08 17:39:34 +02:00
parent b4fb52617a
commit 559d7c0ba0
4 changed files with 27 additions and 17 deletions

View File

@@ -1,6 +1,6 @@
const CopyWebpackPlugin = require('copy-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const { ProvidePlugin } = require('webpack');
const { ProvidePlugin, DefinePlugin } = require('webpack');
const path = require('path');
@@ -12,6 +12,9 @@ module.exports = {
},
devtool: 'source-map',
plugins: [
new DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development')
}),
new ProvidePlugin({
$: 'jquery', // Rende $ disponibile globalmente
jQuery: 'jquery',

View File

@@ -1,7 +1,7 @@
const commonConfiguration = require('./webpack.common.js');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const { ProvidePlugin } = require('webpack');
const { ProvidePlugin, DefinePlugin } = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const path = require('path');
@@ -16,6 +16,9 @@ module.exports = {
},
plugins: [
new CleanWebpackPlugin(),
new DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production')
}),
new ProvidePlugin({
$: 'jquery', // Rende $ disponibile globalmente
jQuery: 'jquery',

View File

@@ -16,16 +16,16 @@ let prescrizione;
let def_config;
let lang = navigator.language.split('-')[0] != 'it' ? 'en' : 'it';
const hidden_fields = {};
let API = 'http://localhost/api/';
let CRM_URL = 'http://localhost/prescrizioni/';
let CFG_URL = 'http://localhost/config-predefinite/';
let API = 'https://lto.test/api/';
let CRM_URL = 'https://lto.test/prescrizioni/';
let CFG_URL = 'https://lto.test/config-predefinite-tads/';
//if(process.env.NODE_ENV === 'production'){
if(process.env.NODE_ENV === 'production'){
API = 'https://setup.allineatoriinvisibili.it/api/';
CRM_URL = 'https://setup.allineatoriinvisibili.it/prescrizioni/';
CFG_URL = 'https://setup.allineatoriinvisibili.it/config-predefinite/';
CFG_URL = 'https://setup.allineatoriinvisibili.it/config-predefinite-tads/';
//}
}
const assetDir = './assets/'
const anteprimaDir = assetDir+'images/anteprima_finiture/';
@@ -108,7 +108,7 @@ export const init = async (_scene, _cameraControls) => {
let edit = url.searchParams.get("edit");
let force_lang = url.searchParams.get("lang");
let force_lang = url.searchParams.get("lang") || localStorage.getItem('lang');
if(force_lang != null){
lang = force_lang;
}else{
@@ -118,18 +118,20 @@ export const init = async (_scene, _cameraControls) => {
if(id != null){
if(type != null && type == 'default'){
def_config = await (await fetch(API+'frontend/def-config/'+id)).json();
fetch(API+'frontend/def-config-tads/'+id).then(res => res.json()).then(data => {
console.log(data);
})
def_config = await (await fetch(API+'frontend/def-config-tads/'+id)).json();
$(".btn-torna-prescrizione").addClass('d-none');
$(".btn-torna-prescrizione-modal").addClass('d-none');
if(demo_mode != null){
$(".btn-salva").addClass('d-none');
$(".btn-torna-prescrizione").addClass('d-none');
}else{
$(".btn-torna-config-modal,.btn-torna-indietro").removeClass('d-none').on('click', ()=>{ location.href = CFG_URL })
}
@@ -139,7 +141,7 @@ export const init = async (_scene, _cameraControls) => {
let cfg = configurazione[k];
$("#"+cfg.field.id).val(cfg.value);
$("#"+cfg.field.id).trigger('change');
//updateConfig(cfg.field, cfg.value, cfg.label)
updateConfig(cfg.field, cfg.value, cfg.label)
}
}
}else{
@@ -150,7 +152,7 @@ export const init = async (_scene, _cameraControls) => {
let ed_config = null;
if(id_config != null){
ed_config = await (await fetch(API+'frontend/def-config/'+id_config)).json();
ed_config = await (await fetch(API+'frontend/def-config-tads/'+id_config)).json();
}
prescrizione = await (await fetch(API+'frontend/config/'+id)).json();
@@ -174,7 +176,7 @@ export const init = async (_scene, _cameraControls) => {
$("#"+cfg.field.id).val(cfg.value);
$("#"+cfg.field.id).trigger('change');
//updateConfig(cfg.field, cfg.value, cfg.label)
updateConfig(cfg.field, cfg.value, cfg.label)
}
}
}
@@ -445,7 +447,7 @@ const salvaConfigurazione = async () => {
let toSend = {configurazione: config, configurazione_html: config_html.innerHTML}
if(def_config != null){
url = API+'frontend/save-def-config';
url = API+'frontend/save-def-config-tads';
toSend.id = def_config.id;
}else{
toSend.prescrizione_id = prescrizione.id;
@@ -498,4 +500,6 @@ window.appendLang = (lang) => {
window.location.href += '?lang='+lang;
}
localStorage.setItem('lang', lang);
}

View File

@@ -342,7 +342,7 @@ export const loadModels = async (config) => {
}
console.log("Active objs:", activeObjs);
//console.log("Active objs:", activeObjs);
mainGroup.traverse((el) => {
if(el.isMesh && el.userData.type != 'arcata') el.visible = false;