{"id":13777947,"url":"https://github.com/samuelsimoes/hanami-webpack","last_synced_at":"2025-05-11T11:34:38.422Z","repository":{"id":56004655,"uuid":"67317235","full_name":"samuelsimoes/hanami-webpack","owner":"samuelsimoes","description":"A RubyGem to allow you to use the Webpack as your asset pipeline in Hanami.","archived":true,"fork":false,"pushed_at":"2020-11-28T22:54:17.000Z","size":9,"stargazers_count":49,"open_issues_count":6,"forks_count":13,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-08-03T18:12:08.447Z","etag":null,"topics":["hanami","rubygems","webpack"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","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/samuelsimoes.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":"2016-09-04T00:04:30.000Z","updated_at":"2024-01-15T10:28:07.000Z","dependencies_parsed_at":"2022-08-15T11:10:48.873Z","dependency_job_id":null,"html_url":"https://github.com/samuelsimoes/hanami-webpack","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuelsimoes%2Fhanami-webpack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuelsimoes%2Fhanami-webpack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuelsimoes%2Fhanami-webpack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuelsimoes%2Fhanami-webpack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/samuelsimoes","download_url":"https://codeload.github.com/samuelsimoes/hanami-webpack/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225043267,"owners_count":17411954,"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":["hanami","rubygems","webpack"],"created_at":"2024-08-03T18:00:49.994Z","updated_at":"2024-11-17T13:31:17.832Z","avatar_url":"https://github.com/samuelsimoes.png","language":"Ruby","funding_links":[],"categories":["Hanami Gem List"],"sub_categories":["Assets"],"readme":"# hanami-webpack\n\n:warning: **This is a very experimental version, but it works, so, be aware!**\n\nThis plugin will help you to use [Webpack](webpack.github.io) as your asset pipeline for Hanami with [webpack-dev-server](http://webpack.github.io/docs/webpack-dev-server.html)  for development.\n\nIt'll work without any problem with your existent assets using the [hanami/assets](https://github.com/hanami/assets).\n\n## Setup\n\nI'll assume that you already have the Node.js installed.\n\n1. Add the `gem 'hanami-webpack', github: 'samuelsimoes/hanami-webpack'` on your Gemfile.\n2. Run `bundle install`.\n3. Copy the base Webpack config **[webpack.config.sample.js](./webpack.config.sample.js)** and **[package.sample.json](./package.sample.json)** on your app root (removing the `.sample` in the name).\n4. Run `npm install`.\n5. Run `bundle exec hanami serve` and profite.\n\n## Usage\n\nOn development, this plugin will try to start the **[webpack-dev-server](http://webpack.github.io/docs/webpack-dev-server.html)** with your Hanami server. You can disable this behavior (see [configuration section](#configuration)).\n\nYou will need use the `webpack_asset_path` helper on your templates to get the correct bundle path.\n\nLet's say that you have a [bundle](http://webpack.github.io/docs/configuration.html#entry) with the name `web.people`. You should place on your template:\n\n```erb\n\u003cscript src=\"\u003c%= webpack_asset_path('web.people') %\u003e\"\u003e\u003c/script\u003e\n```\n\nTo make a build just run `./node_modules/.bin/webpack` on the project root.\n\n## Configuration\n\nAll plugin configuration is done by the following ENV vars:\n\n| Name | Default Value | Description |\n| --- | --- | --- |\n| `WEBPACK_DEV_SERVER_HOST` | `localhost` | The host where your asset dev server is running. |\n| `WEBPACK_DEV_SERVER_PORT` | `3020` | The port where your asset dev server is running. |\n| `WEBPACK_PUBLIC_PATH` | `/` | Whenever you want use other [publicPath](http://webpack.github.io/docs/configuration.html#output-publicpath) you should update this var. |\n| `INBUILT_WEBPACK_DEV_SERVER` | `true` | If you want start the webpack-dev-server when you start your hanami server (except on production). |\n| `WEBPACK_DEV_SERVER` | `false` on production `true` in any other env. | If you want disable the webpack-dev-server integration set this as `false`. |\n| `WEBPACK_MANIFEST_FILE` | `webpack_manifest.json` | The name of the manifest file that exposes the assets path to Hanami. |\n\n## With Heroku\nJust run the command below to configure your Heroku app. This command will set your Hanami app to serve the assets (you probably already done this) and will set the Ruby and Node.js buildpacks.\n\n```\nheroku config:set SERVE_STATIC_ASSETS=true \u0026\u0026 heroku buildpacks:set --index 1 heroku/nodejs \u0026\u0026 heroku buildpacks:set --index 2 heroku/ruby\n```\n\nTo build your assets when you deploy, you will need place on your `package.json` the [Heroku auto-commands](https://devcenter.heroku.com/articles/nodejs-support#heroku-specific-build-steps):\n\n```\n{\n  ...\n  \"scripts\": {\n    \"build\": \"webpack\",\n    \"heroku-postbuild\": \"npm run build\"\n  }\n}\n```\n\n## Todo\n\n* Write tests.\n* Release on RubyGems.\n* Research a better way to do these things without monkey patches (I have done, but looks like that with the current Hanami version it's impossible).\n\n----------\nSamuel Simões ~ [@samuelsimoes](https://twitter.com/samuelsimoes) ~ [Blog](http://blog.samuelsimoes.com/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamuelsimoes%2Fhanami-webpack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsamuelsimoes%2Fhanami-webpack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamuelsimoes%2Fhanami-webpack/lists"}