diff --git a/src/Webpack/ArgumentsHelper.cs b/src/Webpack/ArgumentsHelper.cs index 92588d6..cc066c2 100644 --- a/src/Webpack/ArgumentsHelper.cs +++ b/src/Webpack/ArgumentsHelper.cs @@ -1,10 +1,12 @@ using System.Linq; using System.Text; +using Webpack.Extensions; namespace Webpack { internal class ArgumentsHelper { private const string DefaultDevFile = "--config webpack/webpack.dev.js "; + private const string DevToolType = "--devtool {0} "; private const string CssFiles = "--module-bind css=style!css "; private const string LessFiles = "--module-bind less=style!css!less "; private const string SassFiles = "--module-bind scss=style!css!sass "; @@ -41,6 +43,7 @@ public static string GetWebpackArguments(string rootPath, WebpackOptions options result.Append($"--entry ./{options.EntryPoint} "); result.Append($"--output-path {rootPath} "); result.Append($"--output-filename {options.OutputFileName} "); + result.Append(string.Format(DevToolType, options.DevToolType.GetWebpackValue())); if(options.EnableHotLoading) { result.Append("--hot --inline "); diff --git a/src/Webpack/Extensions/DevToolTypeExtensions.cs b/src/Webpack/Extensions/DevToolTypeExtensions.cs new file mode 100644 index 0000000..9824bd8 --- /dev/null +++ b/src/Webpack/Extensions/DevToolTypeExtensions.cs @@ -0,0 +1,29 @@ +namespace Webpack.Extensions { + + /// + /// Contains extensions methods for + /// + public static class DevToolTypeExtensions { + + /// + /// Returns the webpack required value for the provided + /// + public static string GetWebpackValue(this DevToolType devToolType) { + switch (devToolType) { + case DevToolType.Eval: + return "eval"; + case DevToolType.CheapEvalSourceMap: + return "cheap-eval-source-map"; + case DevToolType.CheapSourceMap: + return "cheap-source-map"; + case DevToolType.CheapModuleEvalSourceMap: + return "cheap-module-eval-source-map"; + case DevToolType.EvalSourceMap: + return "eval-source-map"; + case DevToolType.SourceMap: + return "source-map"; + } + return "source-map"; + } + } +} diff --git a/src/Webpack/WebpackOptions.cs b/src/Webpack/WebpackOptions.cs index fd55dab..09e531b 100644 --- a/src/Webpack/WebpackOptions.cs +++ b/src/Webpack/WebpackOptions.cs @@ -14,6 +14,7 @@ public WebpackOptions( bool handleStyles = true) { EntryPoint = entryPoint; OutputFileName = outputFileName; + DevToolType = DevToolType.SourceMap; EnableES2015 = true; HandleStyles = handleStyles; DevServerOptions = new WebpackDevServerOptions(); @@ -33,6 +34,12 @@ public WebpackOptions( /// public string OutputFileName { get; set; } + /// + /// Indicates the type of the development tool will be used by webpack. See http://webpack.github.io/docs/configuration.html#devtool + /// Default to source-map + /// + public DevToolType DevToolType { get; set; } + /// /// Flag that enables ES2015 features (requires babel-loader to be installed) /// It's enabled true by default @@ -95,6 +102,16 @@ public enum StylesType { Sass } + public enum DevToolType { + Eval, + CheapEvalSourceMap, + CheapSourceMap, + CheapModuleEvalSourceMap, + CheapModuleSourceMap, + EvalSourceMap, + SourceMap + } + public enum StaticFileType { Png, Jpg, diff --git a/src/Webpack/project.json b/src/Webpack/project.json index fdc6d4d..8d57064 100644 --- a/src/Webpack/project.json +++ b/src/Webpack/project.json @@ -1,5 +1,5 @@ { - "version": "1.2.2", + "version": "1.2.3", "title": "Webpack", "description": "Webpack extension methods and middleware for using module bundling in an ASP.NET 5 application", "authors": [ "Charalampos Karypidis" ],