Comments (8)
Reason dev dependencies get installed is that both rails and your rake task run yarn without the --production flag, which is the flag that skips dev dependencies. Not sure if that is intended or not?
I'm running into this right now. I'm using Vue, which uses the NODE_ENV environment var to determine if it should be run in production mode or not. (When I'm deploying, I want it in production mode.) When I set NODE_ENV to production on the production server and deploy, it will fail to build the pack because webpack, et al are "devDependencies" and not "dependencies" in package.json
What is the intended deployment strategy for webpacker? Based on the way webpacker compilation is tagged onto the assets:precompile rake task, it seems like the idea is that we compile on the webpacker assets on deployment server during deployment -- like the assets pipeline assets. Is that correct?
from webpacker.
Also wondering about this commit: 5afa882
If webpack
etc are installed as dev dependencies, they won't be installed on, say Heroku. Does that mean you think assets should be built in a dev environment prior to deploying?
from webpacker.
-
Creating a blank
yarn.lock
file in your root directory tricks Heroku into installing Yarn. -
For compiling your assets before deploying, you can create a rake task. Below is what I've been building off of:
# assets.rake
Rake::Task["assets:precompile"]
.clear_prerequisites
.enhance(["assets:compile_environment"])
namespace :assets do
task compile_environment: [:yarn, :webpack] do
Rake::Task["assets:environment"].invoke
end
desc "Install node deps via yarn"
task :yarn do
sh "bundle exec ./bin/yarn"
end
task :webpack do
sh "bundle exec rails webpacker:compile"
end
end
- I haven't hit any issues deploying to Heroku with webpack listed as a devDependency, but admittedly, I haven't really looked into why!
from webpacker.
@joerodrig3 Do you need the nodejs build pack on Heroku as well? I can't get it to work even with an empty yarn.lock
file in the root directory.
from webpacker.
Yep, any app that uses node needs the nodejs buildpack on Heroku: heroku/nodejs
from webpacker.
Thanks, got it working with the node build pack. Wonder if it would make sense to add node and yarn to the Heroku ruby build pack? I guess a Rails 5.1 app won't function correctly without it?
I grabbed this from rails master which is similar to what you suggested: https://github.com/rails/rails/blob/f04a49b033e3da54a52f76289863ec87a3c30438/railties/lib/rails/tasks/yarn.rake
Reason dev dependencies get installed is that both rails and your rake task run yarn without the --production
flag, which is the flag that skips dev dependencies. Not sure if that is intended or not?
from webpacker.
In #72 dhh stated:
Heroku can update their Yarn detection in time.
So I am going to assume we'll have to wait and see what Heroku does :) Until then the Yarn hack seems like the only way to go. Custom buildpacks may help too. On a work project we did end up modifying one buildpack to fix a ruby version conflict we were having with Webpacker
from webpacker.
Sounds good!
from webpacker.
Related Issues (20)
- Webpacker 6 Disable Babel HOT 1
- Webpacker compilation takes more than 1.5 hours HOT 11
- How do I allow a package in node_modules to be processed by babel? HOT 1
- Remove addition of node_modules to Rails.application.config.assets.paths HOT 1
- V6 Status HOT 3
- Raise an error when javascript_pack_tag or stylesheet_pack_tag are called more than once HOT 1
- Regular Expression Denial of Service in postcss HOT 2
- Intermittent Webpacker.dev_server.running? behavior HOT 2
- Host for assets from a webpacker configuration using custom domains not being resolved HOT 2
- Cherry-pick "Nothing to do" logging update onto `5.x` HOT 1
- Rails 6 WebPacker is not calling JQuery inside views HOT 1
- Security Vulnerability in [email protected] HOT 2
- currently no loaders are configured to process this file HOT 1
- Incompatibility with Ruby 3.2.0 HOT 2
- Confusing gem description on RubyGems HOT 1
- Npm package for 5.4.4 was not released HOT 2
- class variable @@local_levels of ActiveSupport::Logger is overtaken by Logger HOT 2
- Trying to deploy but assets assets:precompile fail
- Security Vulnerability for postcss
- Postcss Security Vulnerability
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from webpacker.