diff --git a/.gitignore b/.gitignore index e495a5a8..b5b2517e 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 56882313..60668132 100644 --- a/zero.Core/Plugins/ZeroPluginOptions.cs +++ b/zero.Core/Plugins/ZeroPluginOptions.cs @@ -11,8 +11,6 @@ namespace zero.Core.Plugins public string Description { get; set; } public List LocalizationPaths { get; private set; } = new List(); - - public string PluginPath { get; set; } } @@ -23,8 +21,6 @@ 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 c48fca8d..1da86373 100644 --- a/zero.Debug/Startup.cs +++ b/zero.Debug/Startup.cs @@ -4,8 +4,6 @@ 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; @@ -60,7 +58,7 @@ namespace zero.Debug app.UseRouting(); app.UseAuthentication(); - app.UseZero(devPath: Path.Combine(Environment.CurrentDirectory, "..", "zero.Web.UI")); + app.UseZero(); app.UseEndpoints(endpoints => { diff --git a/zero.Debug/Views/Shared/Index.cshtml b/zero.Debug/Views/Shared/Index.cshtml new file mode 100644 index 00000000..a949d1a1 --- /dev/null +++ b/zero.Debug/Views/Shared/Index.cshtml @@ -0,0 +1,27 @@ +@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 new file mode 100644 index 00000000..60ed0c0e --- /dev/null +++ b/zero.Debug/Views/Shared/Setup.cshtml @@ -0,0 +1,30 @@ +@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 deleted file mode 100644 index 214388fe..00000000 --- a/zero.Web.UI/.browserslistrc +++ /dev/null @@ -1,3 +0,0 @@ -> 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 new file mode 100644 index 00000000..0b33dac7 Binary files /dev/null and b/zero.Web.UI/Assets/Fonts/Feather/feather.ttf differ diff --git a/zero.Web.UI/Assets/Fonts/Feather/feather.woff b/zero.Web.UI/Assets/Fonts/Feather/feather.woff new file mode 100644 index 00000000..9b03a72a Binary files /dev/null and b/zero.Web.UI/Assets/Fonts/Feather/feather.woff differ diff --git a/zero.Web.UI/Assets/Fonts/Feather/feather.woff2 b/zero.Web.UI/Assets/Fonts/Feather/feather.woff2 new file mode 100644 index 00000000..5c301920 Binary files /dev/null and b/zero.Web.UI/Assets/Fonts/Feather/feather.woff2 differ diff --git a/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Black.woff b/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Black.woff new file mode 100644 index 00000000..d1e2579b Binary files /dev/null and b/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Black.woff differ diff --git a/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Black.woff2 b/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Black.woff2 new file mode 100644 index 00000000..4127b4d0 Binary files /dev/null and b/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Black.woff2 differ diff --git a/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-BlackItalic.woff b/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-BlackItalic.woff new file mode 100644 index 00000000..142c1c9c Binary files /dev/null and b/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-BlackItalic.woff differ diff --git a/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-BlackItalic.woff2 b/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-BlackItalic.woff2 new file mode 100644 index 00000000..e9862e69 Binary files /dev/null and b/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-BlackItalic.woff2 differ diff --git a/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Bold.woff b/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Bold.woff new file mode 100644 index 00000000..cdfcbe0f Binary files /dev/null and b/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Bold.woff differ diff --git a/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Bold.woff2 b/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Bold.woff2 new file mode 100644 index 00000000..2615c853 Binary files /dev/null and b/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Bold.woff2 differ diff --git a/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-BoldItalic.woff b/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-BoldItalic.woff new file mode 100644 index 00000000..3e683fea Binary files /dev/null and b/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-BoldItalic.woff differ diff --git a/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-BoldItalic.woff2 b/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-BoldItalic.woff2 new file mode 100644 index 00000000..f7bace13 Binary files /dev/null and b/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-BoldItalic.woff2 differ diff --git a/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Italic.woff b/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Italic.woff new file mode 100644 index 00000000..d8cf84c8 Binary files /dev/null and b/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Italic.woff differ diff --git a/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Italic.woff2 b/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Italic.woff2 new file mode 100644 index 00000000..aaa5a35c Binary files /dev/null and b/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Italic.woff2 differ diff --git a/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Light.woff b/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Light.woff new file mode 100644 index 00000000..e7d4278c Binary files /dev/null and b/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Light.woff differ diff --git a/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Light.woff2 b/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Light.woff2 new file mode 100644 index 00000000..b6d02883 Binary files /dev/null and b/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Light.woff2 differ diff --git a/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-LightItalic.woff b/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-LightItalic.woff new file mode 100644 index 00000000..bb72fd22 Binary files /dev/null and b/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-LightItalic.woff differ diff --git a/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-LightItalic.woff2 b/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-LightItalic.woff2 new file mode 100644 index 00000000..fc214326 Binary files /dev/null and b/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-LightItalic.woff2 differ diff --git a/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Regular.woff b/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Regular.woff new file mode 100644 index 00000000..bf73a6d9 Binary files /dev/null and b/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Regular.woff differ diff --git a/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Regular.woff2 b/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Regular.woff2 new file mode 100644 index 00000000..a4d084bf Binary files /dev/null and b/zero.Web.UI/Assets/Fonts/Lato/LatoLatin-Regular.woff2 differ diff --git a/zero.Web.UI/Assets/Fonts/TwCenMt/twcenmt-bold.ttf b/zero.Web.UI/Assets/Fonts/TwCenMt/twcenmt-bold.ttf new file mode 100644 index 00000000..b2494b2b Binary files /dev/null and b/zero.Web.UI/Assets/Fonts/TwCenMt/twcenmt-bold.ttf differ diff --git a/zero.Web.UI/Assets/Fonts/TwCenMt/twcenmt-bold.woff b/zero.Web.UI/Assets/Fonts/TwCenMt/twcenmt-bold.woff new file mode 100644 index 00000000..7fd40433 Binary files /dev/null and b/zero.Web.UI/Assets/Fonts/TwCenMt/twcenmt-bold.woff differ diff --git a/zero.Web.UI/Assets/Fonts/TwCenMt/twcenmt-bold.woff2 b/zero.Web.UI/Assets/Fonts/TwCenMt/twcenmt-bold.woff2 new file mode 100644 index 00000000..e59b2620 Binary files /dev/null and b/zero.Web.UI/Assets/Fonts/TwCenMt/twcenmt-bold.woff2 differ diff --git a/zero.Web.UI/Assets/Fonts/TwCenMt/twcenmt-regular.ttf b/zero.Web.UI/Assets/Fonts/TwCenMt/twcenmt-regular.ttf new file mode 100644 index 00000000..a4e3547f Binary files /dev/null and b/zero.Web.UI/Assets/Fonts/TwCenMt/twcenmt-regular.ttf differ diff --git a/zero.Web.UI/Assets/Fonts/TwCenMt/twcenmt-regular.woff b/zero.Web.UI/Assets/Fonts/TwCenMt/twcenmt-regular.woff new file mode 100644 index 00000000..7bfca0a5 Binary files /dev/null and b/zero.Web.UI/Assets/Fonts/TwCenMt/twcenmt-regular.woff differ diff --git a/zero.Web.UI/Assets/Fonts/TwCenMt/twcenmt-regular.woff2 b/zero.Web.UI/Assets/Fonts/TwCenMt/twcenmt-regular.woff2 new file mode 100644 index 00000000..31c0ea19 Binary files /dev/null and b/zero.Web.UI/Assets/Fonts/TwCenMt/twcenmt-regular.woff2 differ diff --git a/zero.Web.UI/Assets/Icons/bird.svg b/zero.Web.UI/Assets/Icons/bird.svg new file mode 100644 index 00000000..e1c8b6c9 --- /dev/null +++ b/zero.Web.UI/Assets/Icons/bird.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/zero.Web.UI/Assets/zero.png b/zero.Web.UI/Assets/zero.png new file mode 100644 index 00000000..a365ee46 Binary files /dev/null and b/zero.Web.UI/Assets/zero.png differ diff --git a/zero.Web.UI/babel.config.js b/zero.Web.UI/babel.config.js deleted file mode 100644 index e9558405..00000000 --- a/zero.Web.UI/babel.config.js +++ /dev/null @@ -1,5 +0,0 @@ -module.exports = { - presets: [ - '@vue/cli-plugin-babel/preset' - ] -} diff --git a/zero.Web.UI/package.json b/zero.Web.UI/package.json index 1d8c111e..c46a8592 100644 --- a/zero.Web.UI/package.json +++ b/zero.Web.UI/package.json @@ -1,15 +1,11 @@ { - "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" + "name": "zero.web", + "version": "1.0.0", + "description": "", + "bin": { + "zero.web": "app.js" }, "dependencies": { - "core-js": "^3.6.5", "axios": "^0.19.2", "dayjs": "^1.8.26", "flatpickr": "^4.6.3", @@ -17,14 +13,43 @@ "sortablejs": "^1.10.2", "underscore": "^1.10.2", "vue": "^2.6.11", - "vue-router": "^3.2.0" + "vue-router": "^3.1.6" }, "devDependencies": { - "@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" - } + "@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" } diff --git a/zero.Web.UI/vue.config.js b/zero.Web.UI/vue.config.js deleted file mode 100644 index c96b5974..00000000 --- a/zero.Web.UI/vue.config.js +++ /dev/null @@ -1,35 +0,0 @@ -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 new file mode 100644 index 00000000..a69ca13b --- /dev/null +++ b/zero.Web.UI/webpack.config.js @@ -0,0 +1,61 @@ +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 new file mode 100644 index 00000000..a1e50c6c --- /dev/null +++ b/zero.Web.UI/webpack.prod.js @@ -0,0 +1,44 @@ +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 c6cfd8bf..a949d1a1 100644 --- a/zero.Web/Views/Shared/Index.cshtml +++ b/zero.Web/Views/Shared/Index.cshtml @@ -12,17 +12,16 @@ - + zero - +
- - + \ No newline at end of file diff --git a/zero.Web/ZeroApplicationBuilderExtensions.cs b/zero.Web/ZeroApplicationBuilderExtensions.cs index 28db8224..9fa7d015 100644 --- a/zero.Web/ZeroApplicationBuilderExtensions.cs +++ b/zero.Web/ZeroApplicationBuilderExtensions.cs @@ -1,13 +1,8 @@ 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; @@ -16,7 +11,7 @@ namespace zero.Web { public static class ZeroApplicationBuilderExtensions { - public static IApplicationBuilder UseZero(this IApplicationBuilder app, string devPath = null) + public static IApplicationBuilder UseZero(this IApplicationBuilder app) { IZeroOptions options = app.ApplicationServices.GetService(); @@ -55,11 +50,6 @@ 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"); }); @@ -69,62 +59,26 @@ 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) { - //IZeroOptions options = app.ApplicationServices.GetService(); - //string zeroPath = options.BackofficePath.EnsureStartsWith('/').TrimEnd('/'); + app.UseDeveloperExceptionPage(); + string webUiPath = path ?? Path.Combine(Environment.CurrentDirectory, "..", "zero.Web.UI"); // TODO dynPATH - //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 => + //app.UseSpa(spa => //{ - // builder.UseRouting(); - - + // spa.Options.SourcePath = webUiPath; + // spa.UseProxyToSpaDevelopmentServer("http://localhost:8999"); //}); - //#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 + #pragma warning disable CS0618 + app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions() + { + HotModuleReplacement = true, + ProjectPath = webUiPath, + HotModuleReplacementServerPort = 8999 + }); + #pragma warning restore CS0618 return app; } diff --git a/zero.Web/zero.Web.csproj b/zero.Web/zero.Web.csproj index 347b9bb8..4e75e8fb 100644 --- a/zero.Web/zero.Web.csproj +++ b/zero.Web/zero.Web.csproj @@ -19,7 +19,6 @@ - @@ -33,13 +32,18 @@ true content\zero\Resources\ + + + true + build\ + - + \ No newline at end of file