All Projects → samuelsimoes → Hanami Webpack

samuelsimoes / Hanami Webpack

Licence: mit
A RubyGem to allow you to use the Webpack as your asset pipeline in Hanami.

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Hanami Webpack

Starling Api Web Starter Kit
Starter kit and example app for using the Starling API.
Stars: ✭ 46 (-8%)
Mutual labels:  webpack
Ng Router Loader
Webpack loader for NgModule lazy loading using the angular router
Stars: ✭ 47 (-6%)
Mutual labels:  webpack
React 5ddm
5d动漫,使用React,服务端渲染,接口(不开源)来自赞片CMS。仅供参考,交流群:14646823 欢迎加入
Stars: ✭ 50 (+0%)
Mutual labels:  webpack
Webpack Webextension Plugin
Webpack plugin that compiles WebExtension manifest.json files and adds smart auto reload
Stars: ✭ 47 (-6%)
Mutual labels:  webpack
Webvr Webpack Boilerplate
A webvr multi-scenes Single-page application for three.js, webpack
Stars: ✭ 47 (-6%)
Mutual labels:  webpack
Wjsp
WEBPACK + JSP 构建多页应用
Stars: ✭ 48 (-4%)
Mutual labels:  webpack
Vue Spa
vue-spa : vue + vue-router + axios + vuex + vux 快速成型移动端项目,直接使用。欢迎star
Stars: ✭ 46 (-8%)
Mutual labels:  webpack
Prepack Webpack Plugin
A webpack plugin for prepack.
Stars: ✭ 1,054 (+2008%)
Mutual labels:  webpack
Jobeir
Building the future of tech jobs search
Stars: ✭ 47 (-6%)
Mutual labels:  webpack
Panic Overlay
Displays JS errors in browsers. Shows sources. Use with any framework. 💥✨
Stars: ✭ 50 (+0%)
Mutual labels:  webpack
Mpvue Loader
mpvue loader
Stars: ✭ 47 (-6%)
Mutual labels:  webpack
Slater Theme
Shopify Starter theme based on slate
Stars: ✭ 47 (-6%)
Mutual labels:  webpack
Webxr Webpack Boilerplate
Starter Kit for building rich, immersive WebXR projects (featuring A-Frame) PWA with Webpack and SASS
Stars: ✭ 48 (-4%)
Mutual labels:  webpack
Bootstrap Loader
Load Bootstrap styles and scripts in your Webpack bundle
Stars: ✭ 1,038 (+1976%)
Mutual labels:  webpack
Razzle React Vue Elm Php Lol
🔥 Blazing fast Razzle app with React, Vue, PHP, and Elm + HMR
Stars: ✭ 50 (+0%)
Mutual labels:  webpack
React Es6 Padawan To Jedi Book
Uma introdução simples e completa para React usando ES6 e Babel.
Stars: ✭ 46 (-8%)
Mutual labels:  webpack
Html Inline Css Webpack Plugin
☄️ A webpack plugin for convert external stylesheet to the embedded stylesheet
Stars: ✭ 48 (-4%)
Mutual labels:  webpack
Typescript Lib Example
Example of TypeScript library setup for multiple compilation targets using tsc and webpack
Stars: ✭ 50 (+0%)
Mutual labels:  webpack
Conditioner
💆🏻 Frizz free, context-aware, JavaScript modules
Stars: ✭ 1,053 (+2006%)
Mutual labels:  webpack
Webpack Handbook
Webpack中文指南
Stars: ✭ 1,050 (+2000%)
Mutual labels:  webpack

hanami-webpack

⚠️ This is a very experimental version, but it works, so, be aware!

This plugin will help you to use Webpack as your asset pipeline for Hanami with webpack-dev-server for development.

It'll work without any problem with your existent assets using the hanami/assets.

Setup

I'll assume that you already have the Node.js installed.

  1. Add the gem 'hanami-webpack', github: 'samuelsimoes/hanami-webpack' on your Gemfile.
  2. Run bundle install.
  3. Copy the base Webpack config webpack.config.sample.js and package.sample.json on your app root (removing the .sample in the name).
  4. Run npm install.
  5. Run bundle exec hanami serve and profite.

Usage

On development, this plugin will try to start the webpack-dev-server with your Hanami server. You can disable this behavior (see configuration section).

You will need use the webpack_asset_path helper on your templates to get the correct bundle path.

Let's say that you have a bundle with the name web.people. You should place on your template:

<script src="<%= webpack_asset_path('web.people') %>"></script>

To make a build just run ./node_modules/.bin/webpack on the project root.

Configuration

All plugin configuration is done by the following ENV vars:

Name Default Value Description
WEBPACK_DEV_SERVER_HOST localhost The host where your asset dev server is running.
WEBPACK_DEV_SERVER_PORT 3020 The port where your asset dev server is running.
WEBPACK_PUBLIC_PATH / Whenever you want use other publicPath you should update this var.
INBUILT_WEBPACK_DEV_SERVER true If you want start the webpack-dev-server when you start your hanami server (except on production).
WEBPACK_DEV_SERVER false on production true in any other env. If you want disable the webpack-dev-server integration set this as false.
WEBPACK_MANIFEST_FILE webpack_manifest.json The name of the manifest file that exposes the assets path to Hanami.

With Heroku

Just 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.

heroku config:set SERVE_STATIC_ASSETS=true && heroku buildpacks:set --index 1 heroku/nodejs && heroku buildpacks:set --index 2 heroku/ruby

To build your assets when you deploy, you will need place on your package.json the Heroku auto-commands:

{
  ...
  "scripts": {
    "build": "webpack",
    "heroku-postbuild": "npm run build"
  }
}

Todo

  • Write tests.
  • Release on RubyGems.
  • 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).

Samuel Simões ~ @samuelsimoes ~ Blog

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].