{"id":19253437,"url":"https://github.com/stevearc/pike","last_synced_at":"2025-06-12T01:33:15.713Z","repository":{"id":17523812,"uuid":"20311863","full_name":"stevearc/pike","owner":"stevearc","description":"Asset pipeline and make tool","archived":false,"fork":false,"pushed_at":"2015-07-22T06:34:08.000Z","size":172,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-08T00:56:11.038Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stevearc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-05-29T23:51:50.000Z","updated_at":"2014-10-06T19:50:45.000Z","dependencies_parsed_at":"2022-09-26T21:31:10.348Z","dependency_job_id":null,"html_url":"https://github.com/stevearc/pike","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/stevearc/pike","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stevearc%2Fpike","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stevearc%2Fpike/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stevearc%2Fpike/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stevearc%2Fpike/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stevearc","download_url":"https://codeload.github.com/stevearc/pike/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stevearc%2Fpike/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259377077,"owners_count":22848285,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T18:30:58.457Z","updated_at":"2025-06-12T01:33:15.677Z","avatar_url":"https://github.com/stevearc.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"Pike\n====\nAn asset pipeline and make tool.\n\n## Getting Started\n\nFirst install Go and configure your GOPATH (see http://golang.org/doc/install).\nThen install pike with:\n\n```\n    go get github.com/stevearc/pike\n```\n\nPike represents all operations as [directed acyclic\ngraphs](http://en.wikipedia.org/wiki/Directed_acyclic_graph). These graphs are\ncomprised of nodes, each of which performs a single, isolated operation. Most\nuse cases will only require simple, linear graphs. Let's look at an example\nthat compiles and minifies LESS files:\n\n```\nn := pike.Glob(\"app/src\", \"*.less\")\nn = n.Pipe(pike.Less())\nn = n.Pipe(pike.CleanCss())\nn = n.Pipe(pike.Write(\"build\"))\n\ng := pike.NewGraph(\"app.less\")\ng.Add(n)\n```\n\nNow let's look at a more complicated example. Coffeescript compiles into\njavascript, but it can also produce source maps for improved debugging. The\ncoffeescript node has multiple outputs for javascript, source maps, and the\noriginal coffeescript files. Let's look at an example that takes advantage of\nthat.\n\n```\nn := pike.Glob(\"app/src\", \"*.coffee\")\n\n// We use Fork instead of Pipe to take advantage of multiple cores\n// The '0' will cause it to create 2*NumCPUs nodes\n// The '3' is the number of output edges on the terminus\nn = n.Fork(pike.Coffee(), 0, 3)\n\n// Since we have 3 output edges, we use Xargs here instead of Pipe\nn = n.Xargs(pike.Write(\"build\"), 3)\n\ng := pike.NewGraph(\"app.js\")\ng.Add(n)\n```\n\n## A Full Example\n\nLet's combine both of the previous graphs into a real file you might use in\nproduction.\n\n```\npackage main\n\nfunc makeAllGraphs(watch bool) []*pike.Graph {\n\tallGraphs := make([]*pike.Graph, 0, 10)\n\n\tn := pike.Glob(\"app/src\", \"*.less\")\n\t// If we're watching for changes, make sure the graph only sends through\n\t// files that have changed.\n\tif watch {\n\t\tn = n.Pipe(pike.ChangeFilter())\n\t}\n\tn = n.Pipe(pike.Less())\n\tn = n.Pipe(pike.CleanCss())\n\t// Write all output file names to the json file\n\tn = n.Pipe(pike.Json(\"app.css\"))\n\tn = n.Pipe(pike.Write(\"build\"))\n\tg := pike.NewGraph(\"app.less\")\n\tg.Add(n)\n\tallGraphs = append(allGraphs, g)\n\n\tn = pike.Glob(\"app/src\", \"*.coffee\")\n\tif watch {\n\t\tn = n.Pipe(pike.ChangeFilter())\n\t\tn = n.Fork(pike.Coffee(), 0, 3)\n\t} else {\n\t\t// If we're not watching for changes, discard source maps\n\t\tn = n.Fork(pike.Coffee(), 0, 1)\n\t\t// Merge all js files into a single file\n\t\tn = n.Pipe(pike.Concat(\"app.js\"))\n\t\t// Minify the final file\n\t\tn = n.Pipe(pike.Uglify())\n\t}\n\tn = n.Xargs(pike.Write(\"build\"), 0)\n\tn = n.Pipe(pike.Json(\"app.js\"))\n\tg = pike.NewGraph(\"app.js\")\n\tg.Add(n)\n\tallGraphs = append(allGraphs, g)\n\n\treturn allGraphs\n}\n\nfunc main() {\n\tpike.Start(makeAllGraphs)\n}\n```\n\nYou can run this file with `go run build.go`. It accepts commandline arguments.\nFor more details run `go run build.go -h`.\n\n## Integration\n\nAfter you build your assets, you will likely need to integrate them somehow\nwith your application. Pike allows you to dump a list of all generated files\ninto a json file, which can then be read by your application. Just call\n`pike.SetJsonFile(\"out.json\")` and put a `pike.Json(\"app.js\")` in each\ngraph.\n\n## Debugging\n\nIf you run into problems with your graphs, it may be useful to visualize what\nthe graphs are doing. You can use the Graph.Dot() method to print it out as dot\nsyntax, or call Graph.Render(\"mygraph.png\") to see an image of what your graph\nlooks like. At the moment it does not display subgraphs very well. Sorry.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstevearc%2Fpike","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstevearc%2Fpike","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstevearc%2Fpike/lists"}