Comments (21)
Nice! okay for @gauravtiwari to close this ticket?
from webpacker.
@sealocal Rails 5.0.1
@gauravtiwari https://github.com/ytbryan/webpacker-demos
gonna be away for the next two days, will look at all these info and dig into it when i'm back.
from webpacker.
@ytbryan this works - https://webpacker-vue.herokuapp.com/ and code here - https://github.com/gauravtiwari/webpacker-vue
The only additions are - adding correct buildpacks for heroku
heroku buildpacks:set heroku/nodejs --index 1
heroku buildpacks:set heroku/ruby --index 2
And add a Procfile to run webpack dev server + configuration in development.rb
and moving all the devDependencies except webpack dev server to dependencies block. Strangely, yarn doesn't seem to install them on production. There are many issues filed on Github in same regards, here is one - yarnpkg/yarn#2739
from webpacker.
@ytbryan Deployed updated version here - https://webpacker-demos-vue.herokuapp.com/ and made PR for you - ytbryan/webpacker-demos#1
from webpacker.
@sealocal everything moved to root folder so, now it's usual setup for yarn. #101
from webpacker.
Which version of Rails are you using?
from webpacker.
@ytbryan Do you have the repo somewhere on github? You generally don't need to do assets:precompile, there is a hook that does that when rails run assets:precompile on production.
webpacker/lib/tasks/webpacker.rake
Line 140 in 652afad
I will try your steps and see if I can reproduce it. Mostly likely it's related to Rails version you have used.
from webpacker.
From the error log above:
remote: sh: 1: ./node_modules/webpack/bin/webpack.js: not found
I suspect that yarn
is not globally available - I've been running into this same problem, but when deploying to Amazon Linux.
Using webpacker 1.0 with Rails 5.0, that hook executes, but webpack.js
is not installed because yarn install
did not successfully install the node_modules
(again, because yarn
is not available) so the assets fail to precompile.
I hope that makes sense!
from webpacker.
Thanks @ytbryan. @sealocal Yes I get the same error that webpack isn't found. If we use node buildpack for heroku it does detects yarn and run yarn install by default, which I can see in the log that it installs all dependencies but not the one listed in devDependencies, that's why it can't find webpack.
from webpacker.
@sealocal This explains more - https://yarnpkg.com/lang/en/docs/cli/install/#toc-yarn-install-production so, perhaps by default the gem installer should list those modules, which will be used in production should be under dependencies by default.
from webpacker.
You're right. I haven't tried deploying my app to Heroku - so I can see that you're saying Heroku installed only the production dependencies.
However, my problem is slightly different. On Beanstalk, yarn is not available to install on Amazon Linux Ruby. I've installed it manually, but would prefer to check for the binary and install upon deploy.
I'm using Beanstalk's Ruby platform:
64bit Amazon Linux 2016.09 v2.3.1 running Ruby 2.3 (Puma)
I can open another issue for discussion around Beanstalk deployment.
from webpacker.
@sealocal You can use .ebextensions as pre deploy hook to setup yarn for linux using this guide - https://yarnpkg.com/en/docs/install/#linux-tab ? As an example (not sure it works though),
# Create a file .ebextensions/yarn.config
# Runs right before `npm install` in '.../50npm.sh'
"/opt/elasticbeanstalk/hooks/appdeploy/pre/49yarn.sh" :
mode: "000775"
owner: root
group: users
content: |
#!/bin/bash
app="/tmp/deployment/application";
# install yarn
wget https://dl.yarnpkg.com/rpm/yarn.repo -O /etc/yum.repos.d/yarn.repo;
curl --silent --location https://rpm.nodesource.com/setup_6.x | bash -;
yum -y install yarn;
# Install deps
cd "${app}";
yarn --production;
Resource: http://www.eq8.eu/blogs/29-aws-elasticbeanstalk-deployment-hooks
from webpacker.
Heroku was discussed over here as well: #90 (comment)
Not sure if DHH still has an opposing view on the topic.
from webpacker.
@gauravtiwari Thanks for the input! Did you grab that yarn.config snippet from StackOverflow? You'll see my comment right below it : D
I get that there are pre/post deploy hooks on AWS, but I haven't found the right combination that works for me. That particular yarn.config
file is for a AWS Elastic Beanstalk Node Platform, where I'm running a Ruby platform. I haven't found the magic combination of commands to issue to AWS on deploy to get yarn installed. Perhaps I'm thinking of it wrong, and I should just install yarn manually upon setting up the application - which I have been able to solve.
from webpacker.
@sealocal Yeah, unfortunately I haven't used beanstalk, just EC2 :)
Is it not possible to manually install node.js platform too alongside ruby one?
from webpacker.
Actually node and npm are installed on the Ruby platform, but installing yarn so that the webapp
user as global access to yarn (so that ./bin/yarn
runs from the Rails root) has still been a challenge for me. I've had success installing globally twice, but failed to install multiple times, so my results are inconsistent.
from webpacker.
I believe even once your buildpacks are set correctly and NPM_CONFIG_PRODUCTION
is set to false
your compilation will still fail due to a problem with the vue preset (see below.) All the more reason to spin these off into separate repos per #124.
Added a #125 so that errors like the below are actually visible. Will maybe add another PR to update the README with some Heroku instructions.
Module build failed: Error:
Vue packages version mismatch:
- [email protected]
- [email protected]
This may cause things to work incorrectly. Make sure to use the same version for both.
If you are using vue-loader@>=10.0, simply update vue-template-compiler.
If you are using vue-loader@<10.0 or vueify, re-installing vue-loader/vueify should bump vue-template-compiler to the latest.
@ytbryan Probably need to specify the vue versions in yarn add
from webpacker.
@dleavitt this PR should fix the error.
Perhaps, in the short run, webpacker might wish to give a warning note to users on managing dependencies with./bin/yarn
from webpacker.
I was having this issue on Heroku and realized it was because yarn won't install devDependencies when NODE_ENV=production. I fixed this by setting heroku config:set YARN_PRODUCTION=false
from webpacker.
@swrobel This is fixed on master, please do bundle update and try again. Let me know.
from webpacker.
@gauravtiwari fixed on master without the ENV var, thanks!
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.