Example #1
0
        public static void Main(string[] args)
        {
            try
            {
                var configFile = new ConfigurationBuilder()
                                 .AddJsonFile(
                    Path.Combine(Environment.CurrentDirectory, "builder/builder-config.json"),
                    optional: false,
                    reloadOnChange: false)
                                 .Build();
                var config = new BuilderConfig();
                configFile.Bind(config);

                var builder = new ProjectBuilder(config);
                builder
                .BuildClient()
                .BuildPreview()
                .BuildMaster()
                .BuildTypeScripts()
                .BuildResources()
                .BuildPreviewOffline()
                .BuildOffline()
                .BuildFinalOutput();
            }
            catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.Error.WriteLine($"Unexpected Error: {ex.Message}");
                throw;
            }
        }
        public virtual ProjectBuilder Build(ProjectBuilder builder)
        {
            var files = GetFiles(FileFilter);

            using (var cache = new BuildCache())
            {
                var changedFiles = files.Where(file => !cache.Contains(file));
                Parallel.ForEach(changedFiles, path =>
                {
                    builder.WriteInfo($"{ResourceType} minify: {path}");

                    var text   = File.ReadAllText(path);
                    var result = Minify(text);

                    var outputPath = GetMinimizedFileName(path);
                    File.WriteAllText(outputPath, result);
                    cache.AddCache(path);

                    builder.WriteHint($"\t=> {outputPath}");
                    // builder.WriteHint($"\t=> {outputPath.PadRight(48)}{(100.0 * result.Length / text.Length):0.##}%");
                });
                cache.SaveCache();
            }
            files.ForEach(file =>
            {
                builder.OriginalResourceLength  += new FileInfo(file).Length;
                builder.MinimizedResourceLength += new FileInfo(GetMinimizedFileName(file)).Length;
            });
            builder.WriteSuccess($"{ResourceType} minify complete.");
            return(builder);
        }
Example #3
0
        public static void Main(string[] args)
        {
            try
            {
                var configFile = new ConfigurationBuilder()
                                 .AddJsonFile(
                    Path.Combine(Environment.CurrentDirectory, "builder/builder-config.json"),
                    optional: false,
                    reloadOnChange: false)
                                 .Build();
                var config = new BuilderConfig();
                configFile.Bind(config);

                var builder = new ProjectBuilder(config);
                builder
                .BuildClient()
                .BuildPreview()
                .BuildMaster()
                .GetBundleFiles()
                .PrebuildVue()
                .BuildTypeScripts()
                .BuildSass()
                .BuildVue()
                .BuildResources()
                .BuildPreviewOffline()
                .BuildOffline()
                .BuildBundle()
                .BuildPreviewData()
                .BuildFinalOutput();

                if (config.CopyOnBuild)
                {
                    var text = File.ReadAllText(config.PreviewOffline);
                    TextCopy.Clipboard.SetText(text);
                    builder.WriteHint($"Copied {text.Length} characters");
                }
            }
            catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.Error.WriteLine($"Unexpected Error: {ex.Message}");
                throw;
            }
        }
Example #4
0
        public static void RunFullBuild()
        {
            var builder = ProjectBuilder.CreateBuilder();

            builder
            .BuildClient()         // inject client files
            .BuildVersions()       // preview file, versions
            .BuildMaster()         // stable source code
            .GetBundleFiles()      // detect if bundle needs rebuild or can skip
            .PrebuildVue()         // generate vue.ts files from vue files
            .BuildTypeScripts()    // build ts files
            .BuildSass()           // build sass files
            .BuildVue()            // build vue files (js, sass, css, html)
            .BuildResources()      // build js, css, html files
            .BuildPreviewOffline() // preview-offline file + offline data
            .BuildOffline()        // offline file + offline data
            .BuildBundle()         // bundle file
            .BuildPreviewData()    // preview online data
            .BuildFinalOutput();   // stable file + online data
        }
 public override ProjectBuilder Build(ProjectBuilder builder)
 {
     base.Build(builder);
     return(builder.BuildDarkStyles());
 }