Skip Navigation
Show nav
Heroku Dev Center Dev Center
  • Get Started
  • Documentation
  • Changelog
  • Search
Heroku Dev Center Dev Center
  • Get Started
    • Node.js
    • Ruby on Rails
    • Ruby
    • Python
    • Java
    • PHP
    • Go
    • Scala
    • Clojure
    • .NET
  • Documentation
  • Changelog
  • More
    Additional Resources
    • Home
    • Elements
    • Products
    • Pricing
    • Careers
    • Help
    • Status
    • Events
    • Podcasts
    • Compliance Center
    Heroku Blog

    Heroku Blog

    Find out what's new with Heroku on our blog.

    Visit Blog
  • Log in or Sign up
View categories

Categories

  • Heroku Architecture
    • Compute (Dynos)
      • Dyno Management
      • Dyno Concepts
      • Dyno Behavior
      • Dyno Reference
      • Dyno Troubleshooting
    • Stacks (operating system images)
    • Networking & DNS
    • Platform Policies
    • Platform Principles
    • Buildpacks
  • Developer Tools
    • AI Tools
    • Command Line
    • Heroku VS Code Extension
  • Deployment
    • Deploying with Git
    • Deploying with Docker
    • Deployment Integrations
  • Continuous Delivery & Integration (Heroku Flow)
    • Continuous Integration
  • Language Support
    • Node.js
      • Working with Node.js
      • Troubleshooting Node.js Apps
      • Node.js Behavior in Heroku
    • Ruby
      • Rails Support
        • Working with Rails
      • Working with Bundler
      • Working with Ruby
      • Ruby Behavior in Heroku
      • Troubleshooting Ruby Apps
    • Python
      • Working with Python
      • Background Jobs in Python
      • Python Behavior in Heroku
      • Working with Django
    • Java
      • Java Behavior in Heroku
      • Working with Java
      • Working with Maven
      • Working with Spring Boot
      • Troubleshooting Java Apps
    • PHP
      • Working with PHP
      • PHP Behavior in Heroku
    • Go
      • Go Dependency Management
    • Scala
    • Clojure
    • .NET
      • Working with .NET
  • Databases & Data Management
    • Heroku Postgres
      • Postgres Basics
      • Postgres Getting Started
      • Postgres Performance
      • Postgres Data Transfer & Preservation
      • Postgres Availability
      • Postgres Special Topics
      • Migrating to Heroku Postgres
    • Heroku Key-Value Store
    • Apache Kafka on Heroku
    • Other Data Stores
  • AI
    • Inference Essentials
    • Inference API
    • Inference Quick Start Guides
    • AI Models
    • Tool Use
    • AI Integrations
    • Vector Database
  • Monitoring & Metrics
    • Logging
  • App Performance
  • Add-ons
    • All Add-ons
  • Collaboration
  • Security
    • App Security
    • Identities & Authentication
      • Single Sign-on (SSO)
    • Private Spaces
      • Infrastructure Networking
    • Compliance
  • Heroku Enterprise
    • Enterprise Accounts
    • Enterprise Teams
  • Patterns & Best Practices
  • Extending Heroku
    • Platform API
    • App Webhooks
    • Heroku Labs
    • Building Add-ons
      • Add-on Development Tasks
      • Add-on APIs
      • Add-on Guidelines & Requirements
    • Building CLI Plugins
    • Developing Buildpacks
    • Dev Center
  • Accounts & Billing
  • Troubleshooting & Support
  • Integrating with Salesforce
    • Heroku AppLink
      • Getting Started with Heroku AppLink
      • Working with Heroku AppLink
      • Heroku AppLink Reference
    • Heroku Connect (Salesforce sync)
      • Heroku Connect Administration
      • Heroku Connect Reference
      • Heroku Connect Troubleshooting
    • Other Salesforce Integrations
  • Language Support
  • Scala
  • Using Node.js to Perform JavaScript Optimization for Play and Scala Applications

Using Node.js to Perform JavaScript Optimization for Play and Scala Applications

English — 日本語に切り替える

Table of Contents [expand]

  • Add the Node.js Buildpack
  • Add a package.json
  • Configure sbt-js-engine
  • Deploy

Last updated February 26, 2026

Some sbt plugins require a JavaScript engine for asset processing. For example, sbt-rjs performs RequireJS optimization and sbt-uglify performs UglifyJS minification. These plugins use sbt-js-engine to run JavaScript, which defaults to Trireme, a JVM-based JavaScript runtime.

Trireme works for small operations, but its performance degrades with large numbers of files. Using a native Node.js engine significantly improves build times. This guide shows how to configure your Play or Scala project to use Node.js for JavaScript processing on Heroku.

Add the Node.js Buildpack

To make Node.js available during your sbt build, add the Node.js buildpack before the Scala buildpack:

$ heroku buildpacks:clear --app example-app
$ heroku buildpacks:add heroku/nodejs --app example-app
$ heroku buildpacks:add heroku/scala --app example-app

Verify the order:

$ heroku buildpacks --app example-app
=== example-app Buildpacks
1. heroku/nodejs
2. heroku/scala

The Node.js buildpack must run first so that node is on the PATH when sbt executes.

Add a package.json

The Node.js buildpack requires a package.json file in your project root. Create a minimal one specifying a Node.js version:

{
  "engines": {
    "node": "24.x"
  }
}

See Heroku Node.js Support for available Node.js versions.

Add the file to your repository:

$ git add package.json
$ git commit -m "Add package.json for Node.js buildpack"

Configure sbt-js-engine

By default, sbt-js-engine uses AutoDetect, which prefers Node.js if it’s available on the PATH. Since the Node.js buildpack installs node before sbt runs, sbt-js-engine picks it up automatically.

If you need to force Node.js explicitly, add the following to your build.sbt:

JsEngineKeys.engineType := JsEngineKeys.EngineType.Node

Or set it via the SBT_OPTS config var:

$ heroku config:set SBT_OPTS="-Dsbt.jse.engineType=Node" --app example-app

Deploy

Deploy your changes:

$ git push heroku main

During the build, the Node.js buildpack installs Node.js first, then the Scala buildpack runs sbt which uses the Node.js engine for JavaScript processing.

For more information, see the sbt-js-engine documentation and Heroku Scala Support.

Feedback

Log in to submit feedback.

Information & Support

  • Getting Started
  • Documentation
  • Changelog
  • Compliance Center
  • Training & Education
  • Blog
  • Support Channels
  • Status

Language Reference

  • Node.js
  • Ruby
  • Java
  • PHP
  • Python
  • Go
  • Scala
  • Clojure
  • .NET

Other Resources

  • Careers
  • Elements
  • Products
  • Pricing
  • RSS
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku Blog
    • Heroku News Blog
    • Heroku Engineering Blog
  • Twitter
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku
    • Heroku Status
  • Github
  • LinkedIn
  • © 2026 Salesforce, Inc. All rights reserved. Various trademarks held by their respective owners. Salesforce Tower, 415 Mission Street, 3rd Floor, San Francisco, CA 94105, United States
  • heroku.com
  • Legal
  • Terms of Service
  • Privacy Information
  • Responsible Disclosure
  • Trust
  • Contact
  • Cookie Preferences
  • Your Privacy Choices