Exemple #1
0
        public static string Minify(string fullFileName, string outputText, ProjectItem projectItem, MinifyType mode, string customArgument)
        {
            if (mode == MinifyType.Unspecified)
            {
                mode = Settings.Instance(fullFileName).DefaultJavaScriptMinifier;
            }

            switch (mode)
            {
            case MinifyType.gctAdvanced:
                return(ClosureCompilerEngine.Minify(fullFileName, outputText, projectItem, ClosureCompilerCompressMode.ADVANCED_OPTIMIZATIONS, customArgument));

            case MinifyType.gctSimple:
                return(ClosureCompilerEngine.Minify(fullFileName, outputText, projectItem, ClosureCompilerCompressMode.SIMPLE_OPTIMIZATIONS, customArgument));

            case MinifyType.gctWhiteSpaceOnly:
                return(ClosureCompilerEngine.Minify(fullFileName, outputText, projectItem, ClosureCompilerCompressMode.WHITESPACE_ONLY, customArgument));

            case MinifyType.msAjax:
                return(MsJsEngine.Minify(fullFileName, outputText, projectItem));

            case MinifyType.uglify:
                return(UglifyEngine.Minify(fullFileName, outputText, projectItem));

            case MinifyType.jsBeautifier:
                return(UglifyEngine.Beautify(outputText));

            default:
                return(YuiJsEngine.Minify(fullFileName, outputText, projectItem));
            }
        }
        public void TestClosureCompilerAdvancedOnlineDetectFileName()
        {
            Settings settings = new Settings();
            settings.GoogleClosureOffline = false;
            settings.ChirpJsFile = ".chirp.js";
            settings.Save();

            string code = "function hello(name) {alert('Hello, ' + name);}hello('New user');";
            //create file for googleClosureCompilerOffline
            string TempFilePath = System.Environment.CurrentDirectory + "\\test.chirp.js";
            System.IO.File.WriteAllText(TempFilePath, code);

            ClosureCompilerEngine closureCompilerEngine = new ClosureCompilerEngine();
            code = closureCompilerEngine.Transform(TempFilePath, code, GetProjectItem(TempFilePath));
            Assert.IsTrue(code == "alert(\"Hello, New user\");\r\n" || code == "alert(\"Hello, New user\");");
        }
Exemple #3
0
        public void LoadActions()
        {
            if (this.engineManager == null || this.engineManager.IsDisposed) {
                this.engineManager = new EngineManager(this);
            }

            this.engineManager.Clear();
            this.engineManager.Add(YuiCssEngine = new YuiCssEngine());
            this.engineManager.Add(YuiJsEngine = new YuiJsEngine());
            this.engineManager.Add(DeanEdwardsPackerEngine = new DeanEdwardsPackerEngine());
            this.engineManager.Add(ClosureCompilerEngine = new ClosureCompilerEngine());
            this.engineManager.Add(LessEngine = new LessEngine());
            this.engineManager.Add(MsJsEngine = new MsJsEngine());
            this.engineManager.Add(MsCssEngine = new MsCssEngine());
            this.engineManager.Add(ConfigEngine = new ConfigEngine());
            this.engineManager.Add(ViewEngine = new ViewEngine());
            this.engineManager.Add(T4Engine = new T4Engine());
            this.engineManager.Add(CoffeeScriptEngine = new CoffeeScriptEngine());
            this.engineManager.Add(UglifyEngine = new UglifyEngine());
            this.engineManager.Add(JSHintEngine = new JSHintEngine());
            this.engineManager.Add(CSSLintEngine = new CSSLintEngine());
            this.engineManager.Add(SassEngine = new SassEngine());
        }