diff --git a/.gitignore b/.gitignore index 64596a30..587b4d29 100644 --- a/.gitignore +++ b/.gitignore @@ -275,4 +275,5 @@ zero.Stories/ zero.Forms/ zero.Web.UI/package.json zero.Web.UI/package-lock.json -zero.Web.UI/app/core/plugins.js \ No newline at end of file +zero.Web.UI/app/core/plugins.js +zero.Web.UI/dist diff --git a/zero.Web.UI/vite.config.js b/zero.Web.UI/vite.config.js index 289d61d2..49395d74 100644 --- a/zero.Web.UI/vite.config.js +++ b/zero.Web.UI/vite.config.js @@ -2,7 +2,14 @@ const path = require('path'); const fs = require('fs'); const { createVuePlugin } = require('vite-plugin-vue2'); -let loadedPlugins = JSON.parse(process.env.ZERO_PLUGINS || "[]"); //["../zero.Commerce/Plugin", "../../Laola/Laola.Backoffice/Plugin"]; +let loadedPlugins = JSON.parse(process.env.ZERO_PLUGINS || "[]"); + + +if (!process.env.ZERO_PLUGINS) +{ + loadedPlugins = ["../zero.Commerce/Plugin", "../zero.Stories/Plugin", "../zero.Forms/Plugin", "../../Laola/Laola.Backoffice/Plugin"]; +} + let zeroPlugins = []; let pluginFileContent = ''; @@ -45,7 +52,10 @@ fs.writeFile(path.resolve(__dirname, 'app/core/plugins.js'), pluginFileContent, //file written successfully }) -const config = { +/** + * @type {import('vite').UserConfig} + */ +let config = { server: { port: process.env.PORT, cors: true @@ -59,15 +69,30 @@ const config = { 'tiptap': 'tiptap/dist/tiptap.esm.js' }, build: { - manifest: false, - rollupOptions: { - format: 'cjs', - entryFileNames: `[name].js`, - chunkFileNames: `[name].js`, - assetFileNames: `[name].[ext]` + manifest: true, + outDir: 'dist/zero', + minify: false, + terserOptions: { + compress: false }, - + rollupOptions: { + output: { + format: 'es', + entryFileNames: `[name].js`, + chunkFileNames: `[name].js`, + assetFileNames: `[name].[ext]` + } + } } }; +if (process.env.NODE_ENV === 'production') +{ + config.base = '/zero/'; + config.alias.tiptap = 'node_modules/tiptap/dist/tiptap.esm.js'; + config.alias.underscore = 'node_modules/underscore/underscore-esm.js'; + config.alias.axios = 'node_modules/axios/dist/axios.js'; + config.alias.dayjs = 'node_modules/dayjs/esm/index.js'; +} + export default config; \ No newline at end of file diff --git a/zero.Web/Views/Zero/Index.cshtml b/zero.Web/Views/Zero/Index.cshtml index ca5df518..da6c8558 100644 --- a/zero.Web/Views/Zero/Index.cshtml +++ b/zero.Web/Views/Zero/Index.cshtml @@ -18,7 +18,9 @@ - + + + zero @@ -34,7 +36,9 @@ window.__zero = @Html.Raw(config); window.zero = window.__zero; - - + + + + \ No newline at end of file diff --git a/zero.Web/ZeroApplicationBuilderExtensions.cs b/zero.Web/ZeroApplicationBuilderExtensions.cs index 18e4f12c..05d38245 100644 --- a/zero.Web/ZeroApplicationBuilderExtensions.cs +++ b/zero.Web/ZeroApplicationBuilderExtensions.cs @@ -1,5 +1,6 @@ using Microsoft.AspNetCore.Builder; using Microsoft.Extensions.DependencyInjection; +using System; using zero.Core.Extensions; using zero.Core.Options; using zero.Core.Routing; @@ -75,6 +76,18 @@ namespace zero.Web // endpoints.MapFallbackToController(options.Routing.NotFoundEndpoint.Action, options.Routing.NotFoundEndpoint.Controller); //} }); + + //return app.Use(async (ctx, next) => + //{ + // await next(); + // if (ctx.Response.StatusCode == 404 && !ctx.Response.HasStarted) + // { + // Console.WriteLine("NotFound0: " + ctx.Request.Path); + // //Re-execute the request so the user gets the error page + // //ctx.Request.Path = "/Pages404"; + // await next(); + // } + //}); } } }