diff --git a/.gitignore b/.gitignore index b5b2517e..e495a5a8 100644 --- a/.gitignore +++ b/.gitignore @@ -266,8 +266,8 @@ App_Data/ **/wwwroot/Media/ **/wwwroot/Uploads/ Temp/ -**/Assets/app.* -**/Assets/setup.* -**/Assets/*.js +**/Assets/**/app.* +**/Assets/**/setup.* +**/Assets/**/*.js deps/*.dll zero.Commerce/ \ No newline at end of file diff --git a/zero.Core/Plugins/ZeroPluginOptions.cs b/zero.Core/Plugins/ZeroPluginOptions.cs index 60668132..56882313 100644 --- a/zero.Core/Plugins/ZeroPluginOptions.cs +++ b/zero.Core/Plugins/ZeroPluginOptions.cs @@ -11,6 +11,8 @@ namespace zero.Core.Plugins public string Description { get; set; } public List LocalizationPaths { get; private set; } = new List(); + + public string PluginPath { get; set; } } @@ -21,6 +23,8 @@ namespace zero.Core.Plugins string Description { get; set; } List LocalizationPaths { get; } + + string PluginPath { get; set; } } diff --git a/zero.Debug/Startup.cs b/zero.Debug/Startup.cs index 1da86373..c48fca8d 100644 --- a/zero.Debug/Startup.cs +++ b/zero.Debug/Startup.cs @@ -4,6 +4,8 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; +using System; +using System.IO; using zero.Commerce; using zero.TestData; using zero.Web; @@ -58,7 +60,7 @@ namespace zero.Debug app.UseRouting(); app.UseAuthentication(); - app.UseZero(); + app.UseZero(devPath: Path.Combine(Environment.CurrentDirectory, "..", "zero.Web.UI")); app.UseEndpoints(endpoints => { diff --git a/zero.Debug/Views/Shared/Index.cshtml b/zero.Debug/Views/Shared/Index.cshtml deleted file mode 100644 index a949d1a1..00000000 --- a/zero.Debug/Views/Shared/Index.cshtml +++ /dev/null @@ -1,27 +0,0 @@ -@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers -@model zero.Web.Models.ZeroBackofficeModel -@{ Layout = null; } - - - - - - - - - - - - - - zero - - -
- - - - \ No newline at end of file diff --git a/zero.Debug/Views/Shared/Setup.cshtml b/zero.Debug/Views/Shared/Setup.cshtml deleted file mode 100644 index 60ed0c0e..00000000 --- a/zero.Debug/Views/Shared/Setup.cshtml +++ /dev/null @@ -1,30 +0,0 @@ -@using zero.Core.Extensions -@inject zero.Core.Options.IZeroOptions Options -@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers -@{ - Layout = null; -} - - - - - - - - - - - - - - zero - - -
- - - - \ No newline at end of file diff --git a/zero.Web.UI/.browserslistrc b/zero.Web.UI/.browserslistrc new file mode 100644 index 00000000..214388fe --- /dev/null +++ b/zero.Web.UI/.browserslistrc @@ -0,0 +1,3 @@ +> 1% +last 2 versions +not dead diff --git a/zero.Web.UI/Assets/Fonts/Feather/feather.ttf b/zero.Web.UI/Assets/Fonts/Feather/feather.ttf deleted file mode 100644 index 0b33dac7..00000000 Binary files a/zero.Web.UI/Assets/Fonts/Feather/feather.ttf and /dev/null differ diff --git a/zero.Web.UI/Assets/Fonts/Feather/feather.woff b/zero.Web.UI/Assets/Fonts/Feather/feather.woff deleted file mode 100644 index 9b03a72a..00000000 Binary files a/zero.Web.UI/Assets/Fonts/Feather/feather.woff and /dev/null differ diff --git a/zero.Web.UI/Assets/Fonts/Feather/feather.woff2 b/zero.Web.UI/Assets/Fonts/Feather/feather.woff2 deleted file mode 100644 index 5c301920..00000000 Binary files a/zero.Web.UI/Assets/Fonts/Feather/feather.woff2 and /dev/null differ diff --git a/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Black.woff b/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Black.woff deleted file mode 100644 index d1e2579b..00000000 Binary files a/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Black.woff and /dev/null differ diff --git a/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Black.woff2 b/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Black.woff2 deleted file mode 100644 index 4127b4d0..00000000 Binary files a/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Black.woff2 and /dev/null differ diff --git a/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-BlackItalic.woff b/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-BlackItalic.woff deleted file mode 100644 index 142c1c9c..00000000 Binary files a/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-BlackItalic.woff and /dev/null differ diff --git a/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-BlackItalic.woff2 b/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-BlackItalic.woff2 deleted file mode 100644 index e9862e69..00000000 Binary files a/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-BlackItalic.woff2 and /dev/null differ diff --git a/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Bold.woff b/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Bold.woff deleted file mode 100644 index cdfcbe0f..00000000 Binary files a/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Bold.woff and /dev/null differ diff --git a/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Bold.woff2 b/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Bold.woff2 deleted file mode 100644 index 2615c853..00000000 Binary files a/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Bold.woff2 and /dev/null differ diff --git a/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-BoldItalic.woff b/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-BoldItalic.woff deleted file mode 100644 index 3e683fea..00000000 Binary files a/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-BoldItalic.woff and /dev/null differ diff --git a/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-BoldItalic.woff2 b/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-BoldItalic.woff2 deleted file mode 100644 index f7bace13..00000000 Binary files a/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-BoldItalic.woff2 and /dev/null differ diff --git a/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Italic.woff b/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Italic.woff deleted file mode 100644 index d8cf84c8..00000000 Binary files a/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Italic.woff and /dev/null differ diff --git a/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Italic.woff2 b/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Italic.woff2 deleted file mode 100644 index aaa5a35c..00000000 Binary files a/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Italic.woff2 and /dev/null differ diff --git a/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Light.woff b/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Light.woff deleted file mode 100644 index e7d4278c..00000000 Binary files a/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Light.woff and /dev/null differ diff --git a/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Light.woff2 b/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Light.woff2 deleted file mode 100644 index b6d02883..00000000 Binary files a/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Light.woff2 and /dev/null differ diff --git a/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-LightItalic.woff b/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-LightItalic.woff deleted file mode 100644 index bb72fd22..00000000 Binary files a/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-LightItalic.woff and /dev/null differ diff --git a/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-LightItalic.woff2 b/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-LightItalic.woff2 deleted file mode 100644 index fc214326..00000000 Binary files a/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-LightItalic.woff2 and /dev/null differ diff --git a/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Regular.woff b/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Regular.woff deleted file mode 100644 index bf73a6d9..00000000 Binary files a/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Regular.woff and /dev/null differ diff --git a/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Regular.woff2 b/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Regular.woff2 deleted file mode 100644 index a4d084bf..00000000 Binary files a/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Regular.woff2 and /dev/null differ diff --git a/zero.Web.UI/Assets/Fonts/TwCenMt/twcenmt-bold.ttf b/zero.Web.UI/Assets/Fonts/TwCenMt/twcenmt-bold.ttf deleted file mode 100644 index b2494b2b..00000000 Binary files a/zero.Web.UI/Assets/Fonts/TwCenMt/twcenmt-bold.ttf and /dev/null differ diff --git a/zero.Web.UI/Assets/Fonts/TwCenMt/twcenmt-bold.woff b/zero.Web.UI/Assets/Fonts/TwCenMt/twcenmt-bold.woff deleted file mode 100644 index 7fd40433..00000000 Binary files a/zero.Web.UI/Assets/Fonts/TwCenMt/twcenmt-bold.woff and /dev/null differ diff --git a/zero.Web.UI/Assets/Fonts/TwCenMt/twcenmt-bold.woff2 b/zero.Web.UI/Assets/Fonts/TwCenMt/twcenmt-bold.woff2 deleted file mode 100644 index e59b2620..00000000 Binary files a/zero.Web.UI/Assets/Fonts/TwCenMt/twcenmt-bold.woff2 and /dev/null differ diff --git a/zero.Web.UI/Assets/Fonts/TwCenMt/twcenmt-regular.ttf b/zero.Web.UI/Assets/Fonts/TwCenMt/twcenmt-regular.ttf deleted file mode 100644 index a4e3547f..00000000 Binary files a/zero.Web.UI/Assets/Fonts/TwCenMt/twcenmt-regular.ttf and /dev/null differ diff --git a/zero.Web.UI/Assets/Fonts/TwCenMt/twcenmt-regular.woff b/zero.Web.UI/Assets/Fonts/TwCenMt/twcenmt-regular.woff deleted file mode 100644 index 7bfca0a5..00000000 Binary files a/zero.Web.UI/Assets/Fonts/TwCenMt/twcenmt-regular.woff and /dev/null differ diff --git a/zero.Web.UI/Assets/Fonts/TwCenMt/twcenmt-regular.woff2 b/zero.Web.UI/Assets/Fonts/TwCenMt/twcenmt-regular.woff2 deleted file mode 100644 index 31c0ea19..00000000 Binary files a/zero.Web.UI/Assets/Fonts/TwCenMt/twcenmt-regular.woff2 and /dev/null differ diff --git a/zero.Web.UI/Assets/Icons/bird.svg b/zero.Web.UI/Assets/Icons/bird.svg deleted file mode 100644 index e1c8b6c9..00000000 --- a/zero.Web.UI/Assets/Icons/bird.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/zero.Web.UI/Assets/zero.png b/zero.Web.UI/Assets/zero.png deleted file mode 100644 index a365ee46..00000000 Binary files a/zero.Web.UI/Assets/zero.png and /dev/null differ diff --git a/zero.Web.UI/babel.config.js b/zero.Web.UI/babel.config.js new file mode 100644 index 00000000..e9558405 --- /dev/null +++ b/zero.Web.UI/babel.config.js @@ -0,0 +1,5 @@ +module.exports = { + presets: [ + '@vue/cli-plugin-babel/preset' + ] +} diff --git a/zero.Web.UI/package.json b/zero.Web.UI/package.json index c46a8592..1d8c111e 100644 --- a/zero.Web.UI/package.json +++ b/zero.Web.UI/package.json @@ -1,11 +1,15 @@ { - "name": "zero.web", - "version": "1.0.0", - "description": "", - "bin": { - "zero.web": "app.js" + "name": "zero", + "version": "0.1.0", + "private": true, + "scripts": { + "serve": "vue-cli-service serve", + "build": "vue-cli-service build", + "build-dev": "vue-cli-service build --mode development", + "watch": "vue-cli-service build --mode development --watch" }, "dependencies": { + "core-js": "^3.6.5", "axios": "^0.19.2", "dayjs": "^1.8.26", "flatpickr": "^4.6.3", @@ -13,43 +17,14 @@ "sortablejs": "^1.10.2", "underscore": "^1.10.2", "vue": "^2.6.11", - "vue-router": "^3.1.6" + "vue-router": "^3.2.0" }, "devDependencies": { - "@babel/core": "^7.9.6", - "@babel/preset-env": "^7.9.6", - "aspnet-webpack": "*", - "babel-loader": "*", - "css-loader": "^3.5.3", - "html-webpack-plugin": "^4.3.0", - "mini-css-extract-plugin": "*", - "node-sass": "^4.14.1", - "optimize-css-assets-webpack-plugin": "*", - "sass-loader": "*", - "style-loader": "*", - "uglifyjs-webpack-plugin": "*", - "vue-loader": "*", - "vue-template-compiler": "*", - "webpack": "^4.43.0", - "webpack-cli": "*", - "webpack-dev-server": "^3.11.0", - "webpack-hot-middleware": "*", - "webpack-merge": "*" - }, - "peerDependencies": { - "vue-template-compiler": "2.6.10" - }, - "scripts": { - "dev": "webpack-dev-server -port 8999 --progress --hot --open", - "debug": "webpack --progress", - "build": "webpack --progress --config webpack.prod.js", - "updatepackages": "node wipe.js && rm -rf node_modules && npm update --save-dev && npm update --save" - }, - "babel": { - "presets": [ - "@babel/env" - ] - }, - "author": "", - "license": "ISC" + "@vue/cli-plugin-babel": "~4.5.0", + "@vue/cli-plugin-router": "~4.5.0", + "@vue/cli-service": "~4.5.0", + "sass": "^1.26.5", + "sass-loader": "^8.0.2", + "vue-template-compiler": "^2.6.11" + } } diff --git a/zero.Web.UI/vue.config.js b/zero.Web.UI/vue.config.js new file mode 100644 index 00000000..c96b5974 --- /dev/null +++ b/zero.Web.UI/vue.config.js @@ -0,0 +1,35 @@ +module.exports = { + + // disable hashes in filenames + filenameHashing: false, + + // delete HTML related webpack plugins + chainWebpack: config => + { + config.plugins.delete('html') + config.plugins.delete('preload') + config.plugins.delete('prefetch') + }, + + // output path + outputDir: "Assets", + + publicPath: "/zero/vue-cli", + + // generated output + pages: { + app: "app.js" + }, + + // webpack configuration + chainWebpack: config => + { + const path = require('path'); + + config.resolve.alias.set('zero', path.resolve(__dirname, 'App')); + config.resolve.alias.set('zerosetup', path.resolve(__dirname, 'Setup')); + config.resolve.alias.set('@', __dirname); + config.resolve.alias.set('shop', path.resolve(__dirname, '../zero.Commerce/Plugins/zero.Commerce')); + config.resolve.alias.set('deps', path.join(__dirname, 'node_modules')); + } +} diff --git a/zero.Web.UI/webpack.config.js b/zero.Web.UI/webpack.config.js deleted file mode 100644 index a69ca13b..00000000 --- a/zero.Web.UI/webpack.config.js +++ /dev/null @@ -1,61 +0,0 @@ -const path = require('path'); -const VueLoaderPlugin = require('vue-loader/lib/plugin'); - -module.exports = { - - // entry point of the app - context: __dirname, - entry: { - app: './app.js', - setup: './Setup/setup.js' - }, - - // dev environment (gets overwritten by prod.js) - mode: 'development', - devtool: 'cheap-module-eval-source-map', - - // output paths - output: { - path: path.resolve(__dirname, 'Assets'), - filename: '[name].js', - publicPath: '/Assets/' - }, - - // map files to vue - resolve: { - extensions: ['.js', '.vue', '.json'], - alias: { - 'vue$': path.join(__dirname, 'node_modules', 'vue/dist/vue.esm.js'), - 'deps': path.join(__dirname, 'node_modules'), - 'zero': path.join(__dirname, 'App'), - 'zerosetup': path.join(__dirname, 'Setup'), - '@': __dirname, - 'shop': path.join(__dirname, '..', 'zero.Commerce/Plugins/zero.Commerce') // TODO dynPATH - } - }, - - // plugins to use - plugins: [ - new VueLoaderPlugin() - ], - - // modules to load - module: { - rules: [ - { - test: /\.vue$/, - exclude: /node_modules/, - loader: 'vue-loader' - }, - { - test: /\.js$/, - exclude: /node_modules/, - loader: 'babel-loader' - }, - { - test: /\.scss$/, - use: ["vue-style-loader", "css-loader", "sass-loader"] - } - ] - } -}; \ No newline at end of file diff --git a/zero.Web.UI/webpack.prod.js b/zero.Web.UI/webpack.prod.js deleted file mode 100644 index a1e50c6c..00000000 --- a/zero.Web.UI/webpack.prod.js +++ /dev/null @@ -1,44 +0,0 @@ -const merge = require('webpack-merge'); -const config = require('./webpack.config.js'); -const MiniCssExtractPlugin = require('mini-css-extract-plugin'); -const UglifyJsPlugin = require("uglifyjs-webpack-plugin"); -const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin"); - -module.exports = merge(config, { - - mode: 'production', - devtool: 'source-map', - - output: { - path: path.resolve(__dirname, 'wwwroot/Assets'), - filename: '[name].js', - publicPath: '/Assets/' - }, - - plugins: [ - new MiniCssExtractPlugin({ - filename: "app.css", - chunkFilename: "[id].css" - }) - ], - - module: { - rules: [ - { - test: /\.scss$/, - use: [ MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader' ] - } - ] - }, - - optimization: { - minimizer: [ - new UglifyJsPlugin({ - cache: true, - parallel: true, - sourceMap: true - }), - new OptimizeCSSAssetsPlugin({}) - ] - } -}); \ No newline at end of file diff --git a/zero.Web/Views/Shared/Index.cshtml b/zero.Web/Views/Shared/Index.cshtml index a949d1a1..c6cfd8bf 100644 --- a/zero.Web/Views/Shared/Index.cshtml +++ b/zero.Web/Views/Shared/Index.cshtml @@ -12,16 +12,17 @@ - + zero - +
- + + \ No newline at end of file diff --git a/zero.Web/ZeroApplicationBuilderExtensions.cs b/zero.Web/ZeroApplicationBuilderExtensions.cs index 9fa7d015..28db8224 100644 --- a/zero.Web/ZeroApplicationBuilderExtensions.cs +++ b/zero.Web/ZeroApplicationBuilderExtensions.cs @@ -1,8 +1,13 @@ using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Routing; +using Microsoft.AspNetCore.SpaServices; using Microsoft.AspNetCore.SpaServices.Webpack; using Microsoft.Extensions.DependencyInjection; using System; +using System.Collections.Generic; using System.IO; +using VueCliMiddleware; using zero.Core.Extensions; using zero.Core.Middlewares; using zero.Core.Options; @@ -11,7 +16,7 @@ namespace zero.Web { public static class ZeroApplicationBuilderExtensions { - public static IApplicationBuilder UseZero(this IApplicationBuilder app) + public static IApplicationBuilder UseZero(this IApplicationBuilder app, string devPath = null) { IZeroOptions options = app.ApplicationServices.GetService(); @@ -50,6 +55,11 @@ namespace zero.Web pattern: path + "/api/{controller}/{action}/{id?}" ); + if (devPath != null) + { + endpoints.MapFallback(path + "/vue-cli/{**path}", CreateVueProxyDelegate(endpoints, new SpaOptions { SourcePath = devPath })); + } + // fallbacks for SPA endpoints.MapFallbackToController(path + "/{**path}", "Index", "Index"); }); @@ -59,26 +69,62 @@ namespace zero.Web } + static RequestDelegate CreateVueProxyDelegate(IEndpointRouteBuilder endpoints, SpaOptions options = null) + { + var app = endpoints.CreateApplicationBuilder(); + app.Use(next => context => + { + context.SetEndpoint(null); + return next(context); + }); + + app.UseSpa(opt => + { + if (options != null) + { + opt.Options.DefaultPage = options.DefaultPage; + opt.Options.DefaultPageStaticFileOptions = options.DefaultPageStaticFileOptions; + opt.Options.SourcePath = options.SourcePath; + opt.Options.StartupTimeout = options.StartupTimeout; + } + + opt.UseVueCli(); + }); + + return app.Build(); + } + + public static IApplicationBuilder UseZeroDevEnvironment(this IApplicationBuilder app, string path = null) { - app.UseDeveloperExceptionPage(); + //IZeroOptions options = app.ApplicationServices.GetService(); + //string zeroPath = options.BackofficePath.EnsureStartsWith('/').TrimEnd('/'); - string webUiPath = path ?? Path.Combine(Environment.CurrentDirectory, "..", "zero.Web.UI"); // TODO dynPATH - //app.UseSpa(spa => + //app.UseDeveloperExceptionPage(); + + //string webUiPath = path ?? Path.Combine(Environment.CurrentDirectory, "..", "zero.Web.UI"); // TODO dynPATH + + // map backoffice + //app.UseWhen(ctx => ctx.Request.Path.ToString().StartsWith(zeroPath), builder => //{ - // spa.Options.SourcePath = webUiPath; - // spa.UseProxyToSpaDevelopmentServer("http://localhost:8999"); + // builder.UseRouting(); + + //}); - #pragma warning disable CS0618 - app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions() - { - HotModuleReplacement = true, - ProjectPath = webUiPath, - HotModuleReplacementServerPort = 8999 - }); - #pragma warning restore CS0618 + //#pragma warning disable CS0618 + //app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions() + //{ + // HotModuleReplacement = true, + // ProjectPath = webUiPath, + // HotModuleReplacementServerPort = 8999, + // EnvironmentVariables = new Dictionary() + // { + // { "ZERO", "hi from zero 0.1" } + // } + //}); + //#pragma warning restore CS0618 return app; } diff --git a/zero.Web/zero.Web.csproj b/zero.Web/zero.Web.csproj index 4e75e8fb..347b9bb8 100644 --- a/zero.Web/zero.Web.csproj +++ b/zero.Web/zero.Web.csproj @@ -19,6 +19,7 @@ + @@ -32,18 +33,13 @@ true content\zero\Resources\ - - - true - build\ - - + \ No newline at end of file