public void GlobalModulesTest() { var container = new Urunium.Stitch.TinyIoC.TinyIoCContainer(); Stitcher.Stitch .UsingContainer(container) .From((source) => { source.RootPath = @"c:\App"; source.EntryPoints = new[] { "./App" }; source.CopyFiles = new[] { "./font.ttf" }; source.Globals = new GlobalsConfig { ["react"] = "React", ["react-dom"] = "ReactDOM" }; }).Into((destination) => { destination.Directory = @"c:\Bundle"; destination.BundleFileName = "app.bundle.js"; }) .WithFileSystem <MyMockFileSystem>() .UsingDefaultTransformers() .Sew(); var fileSystem = container.Resolve <IFileSystem>(); Assert.True(fileSystem.File.Exists(@"c:\Bundle\app.bundle.js")); Assert.True(fileSystem.File.Exists(@"c:\Bundle\font.ttf")); }
public void BuildUsingConfigTest() { var container = new Urunium.Stitch.TinyIoC.TinyIoCContainer(); Stitcher.Stitch .UsingContainer(container) .UsingConfig(new StitchConfig { From = new SourceConfig { RootPath = @"c:\App", EntryPoints = new[] { "./App" }, CopyFiles = new[] { "./font.ttf" } }, Into = new DestinationConfig { Directory = @"c:\Bundle", BundleFileName = "app.bundle.js" }, Extendibility = new PackagerExtendibilityConfig { DI = new Dictionary <string, string> { { "System.IO.Abstractions.IFileSystem, System.IO.Abstractions", "Urunium.Stitch.Tests.StitcherTests+MyMockFileSystem, Urunium.Stitch.Tests" }, { "Urunium.Stitch.PackageBundler, Urunium.Stitch", "Urunium.Stitch.Tests.StitcherTests+MyPackageBundler, Urunium.Stitch.Tests" }, { "Urunium.Stitch.Tests.StitcherTests+ICommentWriter, Urunium.Stitch.Tests", "Urunium.Stitch.Tests.StitcherTests+CommentWriter, Urunium.Stitch.Tests" } }, Transformers = new List <string> { // default transformers "Urunium.Stitch.ModuleTransformers.BabelModuleTransformer", "Urunium.Stitch.ModuleTransformers.LessModuleTransformer", "Urunium.Stitch.ModuleTransformers.SassModuleTransformer", "Urunium.Stitch.ModuleTransformers.Base64ModuleTransformer", // extra transformers "Urunium.Stitch.Tests.StitcherTests+TestModuleTransformer, Urunium.Stitch.Tests", } } }).Sew(); var fileSystem = container.Resolve <IFileSystem>(); Assert.True(fileSystem.File.Exists(@"c:\Bundle\app.bundle.js")); Assert.True(fileSystem.File.Exists(@"c:\Bundle\font.ttf")); Assert.True(fileSystem.File.ReadAllText(@"c:\Bundle\app.bundle.js").Contains("'font.ttf' : function(require, exports, module) ")); Assert.True(fileSystem.File.ReadAllText(@"c:\Bundle\app.bundle.js").Contains("// Comment added from MyPackageBundler")); }
public void BuildUsingJsonConfigTest() { var container = new Urunium.Stitch.TinyIoC.TinyIoCContainer(); var config = @"{ 'From': { 'RootPath': 'c:\\App', 'EntryPoints': ['./App'], 'CopyFiles': ['./font.ttf'] }, 'Into': { 'Directory': 'c:\\Bundle', 'BundleFileName': 'app.bundle.js' }, 'Extendibility': { 'DI': { 'System.IO.Abstractions.IFileSystem, System.IO.Abstractions': 'Urunium.Stitch.Tests.StitcherTests+MyMockFileSystem, Urunium.Stitch.Tests', 'Urunium.Stitch.PackageBundler, Urunium.Stitch': 'Urunium.Stitch.Tests.StitcherTests+MyPackageBundler, Urunium.Stitch.Tests', 'Urunium.Stitch.Tests.StitcherTests+ICommentWriter, Urunium.Stitch.Tests': 'Urunium.Stitch.Tests.StitcherTests+CommentWriter, Urunium.Stitch.Tests' }, 'Transformers': [ 'Urunium.Stitch.ModuleTransformers.BabelModuleTransformer', 'Urunium.Stitch.ModuleTransformers.LessModuleTransformer', 'Urunium.Stitch.ModuleTransformers.SassModuleTransformer', 'Urunium.Stitch.ModuleTransformers.Base64ModuleTransformer', 'Urunium.Stitch.Tests.StitcherTests+TestModuleTransformer, Urunium.Stitch.Tests' ] } }"; Stitcher.Stitch .UsingContainer(container) .UsingJsonConfig(config).Sew(); var fileSystem = container.Resolve <IFileSystem>(); Assert.True(fileSystem.File.Exists(@"c:\Bundle\app.bundle.js")); Assert.True(fileSystem.File.Exists(@"c:\Bundle\font.ttf")); Assert.True(fileSystem.File.ReadAllText(@"c:\Bundle\app.bundle.js").Contains("'font.ttf' : function(require, exports, module) ")); Assert.True(fileSystem.File.ReadAllText(@"c:\Bundle\app.bundle.js").Contains("// Comment added from MyPackageBundler")); }