diff --git a/.vscode/launch.json b/.vscode/launch.json index cb59fb1..99040dc 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -17,7 +17,7 @@ "port": 5858 }, { - "name": ".NET Core Launch (console)", + "name": ".NET Core (Development)", "type": "coreclr", "request": "launch", "preLaunchTask": "dev build", @@ -30,6 +30,20 @@ "externalConsole": false, "stopAtEntry": false, "internalConsoleOptions": "openOnSessionStart" + }, + { + "name": ".NET Core (Production)", + "type": "coreclr", + "request": "launch", + "program": "${workspaceRoot}/dist/Toucan.UI.dll", + "args": [], + "env": { + "ASPNETCORE_ENVIRONMENT": "Production" + }, + "cwd": "${workspaceRoot}/dist", + "externalConsole": true, + "stopAtEntry": false, + "internalConsoleOptions": "openOnSessionStart" } ] } \ No newline at end of file diff --git a/src/server/Startup.cs b/src/server/Startup.cs index dbd3631..dbb48b2 100644 --- a/src/server/Startup.cs +++ b/src/server/Startup.cs @@ -12,6 +12,7 @@ using Toucan.Common.Extensions; using Toucan.Contract; using Toucan.Data; +using System.Collections.Generic; namespace Toucan.Server { @@ -33,6 +34,7 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions() { HotModuleReplacement = true, + HotModuleReplacementEndpoint = "/dist", // this value must be the same as 'output.publicPath' in webpack.config.js ProjectPath = Path.Combine(Directory.GetCurrentDirectory(), @"..\ui") }); } diff --git a/src/ui/package.json b/src/ui/package.json index 5482400..c6c13a0 100644 --- a/src/ui/package.json +++ b/src/ui/package.json @@ -1,6 +1,6 @@ { "name": "toucan.ui", - "version": "2.0.2", + "version": "2.0.4", "description": "UI project for Toucan template", "keywords": [ "vuejs", @@ -67,4 +67,4 @@ "webpack-hot-middleware": "^2.18.0", "webpack-merge": "^4.1.0" } -} +} \ No newline at end of file diff --git a/src/ui/webpack-base.js b/src/ui/webpack-base.js index ebbc70c..90b550c 100644 --- a/src/ui/webpack-base.js +++ b/src/ui/webpack-base.js @@ -4,7 +4,7 @@ const merge = require('webpack-merge'); const autoprefixer = require('autoprefixer'); const webpackHtml = require('html-webpack-plugin'); -module.exports = (outputPath, srcPath) => { +module.exports = (outputPath, srcPath, publicPath) => { const plugins = [ @@ -130,7 +130,7 @@ module.exports = (outputPath, srcPath) => { }, output: { path: outputPath, - publicPath: '/', + publicPath: publicPath, filename: '[name].js' }, plugins: plugins, diff --git a/src/ui/webpack.config.js b/src/ui/webpack.config.js index 3f4342a..dad0e22 100644 --- a/src/ui/webpack.config.js +++ b/src/ui/webpack.config.js @@ -11,7 +11,8 @@ module.exports = () => { const srcPath = path.resolve(__dirname, './app'); - const config = webpackBase(outputPath, srcPath); + // set publicPath to '/dist/' is so that .net core webpack middleware can proxy incoming requests to node.js middleware + const config = webpackBase(outputPath, srcPath, '/dist/'); const definePlugin = new webpack.DefinePlugin({ 'process.env.NODE_ENV': '"development"' diff --git a/src/ui/webpack.production.js b/src/ui/webpack.production.js index 9c95b64..cb8a0c3 100644 --- a/src/ui/webpack.production.js +++ b/src/ui/webpack.production.js @@ -11,7 +11,7 @@ module.exports = () => { const srcPath = path.resolve(__dirname, './app'); - const config = webpackBase(outputPath, srcPath); + const config = webpackBase(outputPath, srcPath, '/'); const definePlugin = new webpack.DefinePlugin({ 'process.env.NODE_ENV': '"production"'