production build of zero works (DRAFT), wooohoo 😍

This commit is contained in:
2021-07-22 15:47:40 +02:00
parent bba48e8722
commit 8e18c68317
4 changed files with 56 additions and 13 deletions
+2 -1
View File
@@ -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
zero.Web.UI/app/core/plugins.js
zero.Web.UI/dist
+34 -9
View File
@@ -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;
+7 -3
View File
@@ -18,7 +18,9 @@
<link rel="shortcut icon" type="image/png" href="/assets/zero-icon.png" sizes="196x196">
<base href="~/">
<environment exclude="Development">
<link href="~/zero/Assets/app.css" rel="stylesheet" asp-append-version="true" />
<script type="module" crossorigin src="~/zero/index.js"></script>
<link rel="modulepreload" href="~/zero/vendor.js" />
<link rel="stylesheet" href="~/zero/index.css" />
</environment>
<title>zero</title>
</head>
@@ -34,7 +36,9 @@
window.__zero = @Html.Raw(config);
window.zero = window.__zero;
</script>
<script type="module" src="http://localhost:@(Model.Port)/vite/client"></script>
<script type="module" src="http://localhost:@(Model.Port)/app/app.js"></script>
<environment include="Development">
<script type="module" src="http://localhost:@(Model.Port)/vite/client"></script>
<script type="module" src="http://localhost:@(Model.Port)/app/app.js"></script>
</environment>
</body>
</html>
@@ -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();
// }
//});
}
}
}