Skip to content

Commit 1e74bca

Browse files
committed
#11 Add option for specifying the development tool that is used from webpack
1 parent bcff3d6 commit 1e74bca

File tree

4 files changed

+50
-1
lines changed

4 files changed

+50
-1
lines changed

src/Webpack/ArgumentsHelper.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
using System.Linq;
22
using System.Text;
3+
using Webpack.Extensions;
34

45
namespace Webpack {
56
internal class ArgumentsHelper {
67

78
private const string DefaultDevFile = "--config webpack/webpack.dev.js ";
9+
private const string DevToolType = "--devtool {0} ";
810
private const string CssFiles = "--module-bind css=style!css ";
911
private const string LessFiles = "--module-bind less=style!css!less ";
1012
private const string SassFiles = "--module-bind scss=style!css!sass ";
@@ -41,6 +43,7 @@ public static string GetWebpackArguments(string rootPath, WebpackOptions options
4143
result.Append($"--entry ./{options.EntryPoint} ");
4244
result.Append($"--output-path {rootPath} ");
4345
result.Append($"--output-filename {options.OutputFileName} ");
46+
result.Append(string.Format(DevToolType, options.DevToolType.GetWebpackValue()));
4447

4548
if(options.EnableHotLoading) {
4649
result.Append("--hot --inline ");
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
namespace Webpack.Extensions {
2+
3+
/// <summary>
4+
/// Contains extensions methods for <see cref="DevToolType"/>
5+
/// </summary>
6+
public static class DevToolTypeExtensions {
7+
8+
/// <summary>
9+
/// Returns the webpack required value for the provided <paramref name="devToolType"/>
10+
/// </summary>
11+
public static string GetWebpackValue(this DevToolType devToolType) {
12+
switch (devToolType) {
13+
case DevToolType.Eval:
14+
return "eval";
15+
case DevToolType.CheapEvalSourceMap:
16+
return "cheap-eval-source-map";
17+
case DevToolType.CheapSourceMap:
18+
return "cheap-source-map";
19+
case DevToolType.CheapModuleEvalSourceMap:
20+
return "cheap-module-eval-source-map";
21+
case DevToolType.EvalSourceMap:
22+
return "eval-source-map";
23+
case DevToolType.SourceMap:
24+
return "source-map";
25+
}
26+
return "source-map";
27+
}
28+
}
29+
}

src/Webpack/WebpackOptions.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public WebpackOptions(
1414
bool handleStyles = true) {
1515
EntryPoint = entryPoint;
1616
OutputFileName = outputFileName;
17+
DevToolType = DevToolType.SourceMap;
1718
EnableES2015 = true;
1819
HandleStyles = handleStyles;
1920
DevServerOptions = new WebpackDevServerOptions();
@@ -33,6 +34,12 @@ public WebpackOptions(
3334
/// </summary>
3435
public string OutputFileName { get; set; }
3536

37+
/// <summary>
38+
/// Indicates the type of the development tool will be used by webpack. See http://webpack.github.io/docs/configuration.html#devtool
39+
/// Default to source-map
40+
/// </summary>
41+
public DevToolType DevToolType { get; set; }
42+
3643
/// <summary>
3744
/// Flag that enables ES2015 features (requires babel-loader to be installed)
3845
/// It's enabled <c>true</c> by default
@@ -95,6 +102,16 @@ public enum StylesType {
95102
Sass
96103
}
97104

105+
public enum DevToolType {
106+
Eval,
107+
CheapEvalSourceMap,
108+
CheapSourceMap,
109+
CheapModuleEvalSourceMap,
110+
CheapModuleSourceMap,
111+
EvalSourceMap,
112+
SourceMap
113+
}
114+
98115
public enum StaticFileType {
99116
Png,
100117
Jpg,

src/Webpack/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "1.2.2",
2+
"version": "1.2.3",
33
"title": "Webpack",
44
"description": "Webpack extension methods and middleware for using module bundling in an ASP.NET 5 application",
55
"authors": [ "Charalampos Karypidis" ],

0 commit comments

Comments
 (0)