Skip to content

Commit ada2a7a

Browse files
electricessenceMarkPieszak
electricessence
authored andcommitted
chore(ewbpack): fix webpack warnings & sitemap.xml
* Migrated plugin to shared config. Eliminates webpack warning. * Added placeholder awaits. Eliminates initial warnings. * Changed to pure XML with format string. "localhost" removed as well. * format update. * Revised after testing.
1 parent 5696d03 commit ada2a7a

File tree

2 files changed

+27
-32
lines changed

2 files changed

+27
-32
lines changed

Server/Controllers/HomeController.cs

+17-18
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using System.Diagnostics;
1212
using System;
1313
using Asp2017.Server.Models;
14+
using System.Text.RegularExpressions;
1415

1516
namespace AspCoreServer.Controllers
1617
{
@@ -32,26 +33,24 @@ public async Task<IActionResult> Index()
3233
return View();
3334
}
3435

36+
const string SITEMAP_XML =
37+
@"<?xml version=""1.0"" encoding=""utf-8""?>
38+
<sitemapindex xmlns=""http://www.sitemaps.org/schemas/sitemap/0.9"">
39+
<sitemap>
40+
<loc>/home</loc>
41+
<lastmod>{0}</lastmod>
42+
</sitemap>
43+
<sitemap>
44+
<loc>/counter</loc>
45+
<lastmod>{0}</lastmod>
46+
</sitemap>
47+
</sitemapindex>
48+
";
49+
3550
[HttpGet]
3651
[Route("sitemap.xml")]
37-
public async Task<IActionResult> SitemapXml()
38-
{
39-
String xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
40-
41-
xml += "<sitemapindex xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">";
42-
xml += "<sitemap>";
43-
xml += "<loc>http://localhost:4251/home</loc>";
44-
xml += "<lastmod>" + DateTime.Now.ToString("yyyy-MM-dd") + "</lastmod>";
45-
xml += "</sitemap>";
46-
xml += "<sitemap>";
47-
xml += "<loc>http://localhost:4251/counter</loc>";
48-
xml += "<lastmod>" + DateTime.Now.ToString("yyyy-MM-dd") + "</lastmod>";
49-
xml += "</sitemap>";
50-
xml += "</sitemapindex>";
51-
52-
return Content(xml, "text/xml");
53-
54-
}
52+
public IActionResult SitemapXml()
53+
=> Content(string.Format(SITEMAP_XML, DateTime.Now.ToString("yyyy-MM-dd")));
5554

5655
public IActionResult Error()
5756
{

webpack.config.js

+10-14
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,15 @@ module.exports = (env) => {
3737
...sharedModuleRules
3838
]
3939
},
40-
plugins: [new CheckerPlugin()]
40+
plugins: [
41+
new CheckerPlugin(),
42+
new webpack.ContextReplacementPlugin(
43+
// fixes WARNING Critical dependency: the request of a dependency is an expression
44+
/(.+)?angular(\\|\/)core(.+)?/,
45+
path.join(__dirname, 'src'), // location of your src
46+
{} // a map of your routes
47+
),
48+
]
4149
};
4250

4351
// Configuration for client-side bundle suitable for running in browsers
@@ -89,19 +97,7 @@ module.exports = (env) => {
8997
manifest: require('./ClientApp/dist/vendor-manifest.json'),
9098
sourceType: 'commonjs2',
9199
name: './vendor'
92-
}),
93-
new webpack.ContextReplacementPlugin(
94-
// fixes WARNING Critical dependency: the request of a dependency is an expression
95-
/(.+)?angular(\\|\/)core(.+)?/,
96-
path.join(__dirname, 'src'), // location of your src
97-
{} // a map of your routes
98-
),
99-
new webpack.ContextReplacementPlugin(
100-
// fixes WARNING Critical dependency: the request of a dependency is an expression
101-
/(.+)?express(\\|\/)(.+)?/,
102-
path.join(__dirname, 'src'),
103-
{}
104-
)
100+
})
105101
].concat(isDevBuild ? [] : [
106102
// new webpack.optimize.UglifyJsPlugin({
107103
// compress: false,

0 commit comments

Comments
 (0)