Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
app
bin
config
lib
log
my_engine
public
tmp
vendor
.gitignore
Gemfile
Gemfile.lock
README.md
Rakefile
config.ru
package-lock.json
package.json
webpack.config.js

README.md

Simpacker Rails Engines example

Settings for engine

my_engine/config/simpacker.yml

default: &default
  manifest_path: public/packs/my_engine/manifest.json

development:
  <<: *default
  cache_manifest: false

test:
  <<: *default
  cache_manifest: false

production:
  <<: *default
  cache_manifest: true

my_engine/lib/my_engine.rb

require "my_engine/engine"

module MyEngine
  ROOT_PATH = Pathname.new(File.join(__dir__, ".."))

  def self.simpacker_context
    @simpacker_context ||= Simpacker::Context.new(root_path: ROOT_PATH)
  end
end

my_engine/app/helpers/my_engine/application_helper.rb

module MyEngine
  module ApplicationHelper
    include Simpacker::Helper

    def simpacker_context
      MyEngine.simpacker_context
    end
  end
end

Serving

# config/application.rb
config.middleware.use(Rack::Static, urls: ["/packs/my_engine"], root: MyEngine::Engine.root.join("public"))
You can’t perform that action at this time.