/// <summary> /// Call this method for any extra processing that needs to be done on a script resource before /// being written to the response. /// </summary> /// <param name="script"></param> /// <param name="filePath"></param> /// <param name="shouldMinify"></param> /// <returns></returns> private static string ProcessScript(string script, string filePath, bool shouldMinify) { // The HardMinify call is for backwards compatibility. It's really not needed anymore. if ((shouldMinify) || HardMinify(filePath)) { var min = new JavascriptMinifier(); min.VariableMinification = VariableMinification.LocalVariablesOnly; return(min.Minify(script)); } else { return(script); } }
/// <summary> /// Call this method for any extra processing that needs to be done on a script resource before /// being wriiten to the response. /// </summary> /// <param name="script"></param> /// <param name="filePath"></param> /// <param name="shouldMinify"></param> /// <returns></returns> private static string ProcessScript(string script, string filePath, bool shouldMinify) { if ((shouldMinify)) { var min = new JavascriptMinifier(); // Variable minification would bring some problems to js, so // keep this option be VariableMinification.None for safer! min.VariableMinification = VariableMinification.None; return(min.Minify(script)); } else { return(script); } }
protected override void OnFileChanged(FileSystemEventArgs e) { builder.WriteInfo($"[Vue] {e.Name} changed."); var source = File.ReadAllText(e.FullPath); var vueFile = new VueFile(source); var compiledText = new StringBuilder(""); BuildTemplate(e.FullPath, vueFile, compiledText); BuildStyle(e.FullPath, vueFile, compiledText); BuildScript(e.FullPath, vueFile, compiledText); var minFile = $"min{Path.DirectorySeparatorChar + Path.GetFileName(e.FullPath)}.min.js"; var minifier = new JavascriptMinifier(); File.WriteAllText(minFile, minifier.Minify(compiledText.ToString())); builder.UpdateCachedMinFile(minFile); cache.AddCache(e.FullPath); cache.SaveCache(); }
/// <summary> /// Call this method for any extra processing that needs to be done on a script resource before /// being written to the response. /// </summary> /// <param name="script"></param> /// <param name="filePath"></param> /// <param name="shouldMinify"></param> /// <returns></returns> private static string ProcessScript(string script, string filePath, bool shouldMinify) { // The HardMinify call is for backwards compatibility. It's really not needed anymore. if ((shouldMinify) || HardMinify(filePath)) { var min = new JavascriptMinifier(); min.VariableMinification = VariableMinification.LocalVariablesOnly; return min.Minify(script); } else { return script; } }