Run rails-react with webpacker in production mode. assets:precompile takes very much time
I have a project on rails-react with webpacker. It works perfectly on development mode, but I cannot run it on production mode.
I run it inside docker container:
FROM ruby:2.5.1
# Install dependencies
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev
RUN apt-get update
&& apt-get install -y xvfb qt5-default libqt5webkit5-dev
gstreamer1.0-plugins-base gstreamer1.0-tools gstreamer1.0-x
# Node.js
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash -
&& apt-get install -y nodejs
# yarn
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
&& apt-get update
&& apt-get install -y yarn
# Adding gems
COPY Gemfile Gemfile
COPY Gemfile.lock Gemfile.lock
RUN bundle install
# Adding project files
COPY . .
RUN yarn install
RUN bundle exec rails assets:precompile
RUN bundle exec rails webpacker:compile
Here is my config/environments/production.rb
file
config.cache_classes = false
config.eager_load = false
config.consider_all_requests_local = false
if Rails.root.join('tmp', 'caching-dev.txt').exist?
config.action_controller.perform_caching = true
config.cache_store = :memory_store
config.public_file_server.headers =
'Cache-Control' => "public, max-age=#2.days.to_i"
else
config.action_controller.perform_caching = false
config.cache_store = :null_store
end
config.active_storage.service = :local
config.action_mailer.raise_delivery_errors = false
config.action_mailer.perform_caching = false
config.active_support.deprecation = :log
config.active_record.migration_error = :page_load
config.active_record.verbose_query_logs = true
config.assets.debug = true
config.assets.compile = false
config.assets.compress = true
config.assets.logger = Logger.new $stdout
config.assets.quiet = true
When I try to run rails assets:precompile
on my local machine it takes abouut 1 hour and nothing happens.
And when I try to run docker, It says that Your Yarn packages are out of date!
And suggests to do yarn install. I even tryed this with removing yarn.lock file.
Below is my webpacker.yml config:
production:
source_path: app/javascript
source_entry_path: packs
public_output_path: packs
cache_path: tmp/cache/webpacker
resolved_paths:
extensions:
- .tsx
- .ts
- .mjs
- .jsx
- .js
- .sass
- .scss
- .css
- .module.sass
- .module.scss
- .module.css
- .png
- .svg
- .gif
- .jpeg
- .jpg
compile: false
cache_manifest: true
Any help would be useful as I don't have much experience in using webpacker.
ruby-on-rails reactjs typescript webpack production-environment
add a comment |
I have a project on rails-react with webpacker. It works perfectly on development mode, but I cannot run it on production mode.
I run it inside docker container:
FROM ruby:2.5.1
# Install dependencies
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev
RUN apt-get update
&& apt-get install -y xvfb qt5-default libqt5webkit5-dev
gstreamer1.0-plugins-base gstreamer1.0-tools gstreamer1.0-x
# Node.js
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash -
&& apt-get install -y nodejs
# yarn
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
&& apt-get update
&& apt-get install -y yarn
# Adding gems
COPY Gemfile Gemfile
COPY Gemfile.lock Gemfile.lock
RUN bundle install
# Adding project files
COPY . .
RUN yarn install
RUN bundle exec rails assets:precompile
RUN bundle exec rails webpacker:compile
Here is my config/environments/production.rb
file
config.cache_classes = false
config.eager_load = false
config.consider_all_requests_local = false
if Rails.root.join('tmp', 'caching-dev.txt').exist?
config.action_controller.perform_caching = true
config.cache_store = :memory_store
config.public_file_server.headers =
'Cache-Control' => "public, max-age=#2.days.to_i"
else
config.action_controller.perform_caching = false
config.cache_store = :null_store
end
config.active_storage.service = :local
config.action_mailer.raise_delivery_errors = false
config.action_mailer.perform_caching = false
config.active_support.deprecation = :log
config.active_record.migration_error = :page_load
config.active_record.verbose_query_logs = true
config.assets.debug = true
config.assets.compile = false
config.assets.compress = true
config.assets.logger = Logger.new $stdout
config.assets.quiet = true
When I try to run rails assets:precompile
on my local machine it takes abouut 1 hour and nothing happens.
And when I try to run docker, It says that Your Yarn packages are out of date!
And suggests to do yarn install. I even tryed this with removing yarn.lock file.
Below is my webpacker.yml config:
production:
source_path: app/javascript
source_entry_path: packs
public_output_path: packs
cache_path: tmp/cache/webpacker
resolved_paths:
extensions:
- .tsx
- .ts
- .mjs
- .jsx
- .js
- .sass
- .scss
- .css
- .module.sass
- .module.scss
- .module.css
- .png
- .svg
- .gif
- .jpeg
- .jpg
compile: false
cache_manifest: true
Any help would be useful as I don't have much experience in using webpacker.
ruby-on-rails reactjs typescript webpack production-environment
add a comment |
I have a project on rails-react with webpacker. It works perfectly on development mode, but I cannot run it on production mode.
I run it inside docker container:
FROM ruby:2.5.1
# Install dependencies
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev
RUN apt-get update
&& apt-get install -y xvfb qt5-default libqt5webkit5-dev
gstreamer1.0-plugins-base gstreamer1.0-tools gstreamer1.0-x
# Node.js
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash -
&& apt-get install -y nodejs
# yarn
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
&& apt-get update
&& apt-get install -y yarn
# Adding gems
COPY Gemfile Gemfile
COPY Gemfile.lock Gemfile.lock
RUN bundle install
# Adding project files
COPY . .
RUN yarn install
RUN bundle exec rails assets:precompile
RUN bundle exec rails webpacker:compile
Here is my config/environments/production.rb
file
config.cache_classes = false
config.eager_load = false
config.consider_all_requests_local = false
if Rails.root.join('tmp', 'caching-dev.txt').exist?
config.action_controller.perform_caching = true
config.cache_store = :memory_store
config.public_file_server.headers =
'Cache-Control' => "public, max-age=#2.days.to_i"
else
config.action_controller.perform_caching = false
config.cache_store = :null_store
end
config.active_storage.service = :local
config.action_mailer.raise_delivery_errors = false
config.action_mailer.perform_caching = false
config.active_support.deprecation = :log
config.active_record.migration_error = :page_load
config.active_record.verbose_query_logs = true
config.assets.debug = true
config.assets.compile = false
config.assets.compress = true
config.assets.logger = Logger.new $stdout
config.assets.quiet = true
When I try to run rails assets:precompile
on my local machine it takes abouut 1 hour and nothing happens.
And when I try to run docker, It says that Your Yarn packages are out of date!
And suggests to do yarn install. I even tryed this with removing yarn.lock file.
Below is my webpacker.yml config:
production:
source_path: app/javascript
source_entry_path: packs
public_output_path: packs
cache_path: tmp/cache/webpacker
resolved_paths:
extensions:
- .tsx
- .ts
- .mjs
- .jsx
- .js
- .sass
- .scss
- .css
- .module.sass
- .module.scss
- .module.css
- .png
- .svg
- .gif
- .jpeg
- .jpg
compile: false
cache_manifest: true
Any help would be useful as I don't have much experience in using webpacker.
ruby-on-rails reactjs typescript webpack production-environment
I have a project on rails-react with webpacker. It works perfectly on development mode, but I cannot run it on production mode.
I run it inside docker container:
FROM ruby:2.5.1
# Install dependencies
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev
RUN apt-get update
&& apt-get install -y xvfb qt5-default libqt5webkit5-dev
gstreamer1.0-plugins-base gstreamer1.0-tools gstreamer1.0-x
# Node.js
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash -
&& apt-get install -y nodejs
# yarn
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
&& apt-get update
&& apt-get install -y yarn
# Adding gems
COPY Gemfile Gemfile
COPY Gemfile.lock Gemfile.lock
RUN bundle install
# Adding project files
COPY . .
RUN yarn install
RUN bundle exec rails assets:precompile
RUN bundle exec rails webpacker:compile
Here is my config/environments/production.rb
file
config.cache_classes = false
config.eager_load = false
config.consider_all_requests_local = false
if Rails.root.join('tmp', 'caching-dev.txt').exist?
config.action_controller.perform_caching = true
config.cache_store = :memory_store
config.public_file_server.headers =
'Cache-Control' => "public, max-age=#2.days.to_i"
else
config.action_controller.perform_caching = false
config.cache_store = :null_store
end
config.active_storage.service = :local
config.action_mailer.raise_delivery_errors = false
config.action_mailer.perform_caching = false
config.active_support.deprecation = :log
config.active_record.migration_error = :page_load
config.active_record.verbose_query_logs = true
config.assets.debug = true
config.assets.compile = false
config.assets.compress = true
config.assets.logger = Logger.new $stdout
config.assets.quiet = true
When I try to run rails assets:precompile
on my local machine it takes abouut 1 hour and nothing happens.
And when I try to run docker, It says that Your Yarn packages are out of date!
And suggests to do yarn install. I even tryed this with removing yarn.lock file.
Below is my webpacker.yml config:
production:
source_path: app/javascript
source_entry_path: packs
public_output_path: packs
cache_path: tmp/cache/webpacker
resolved_paths:
extensions:
- .tsx
- .ts
- .mjs
- .jsx
- .js
- .sass
- .scss
- .css
- .module.sass
- .module.scss
- .module.css
- .png
- .svg
- .gif
- .jpeg
- .jpg
compile: false
cache_manifest: true
Any help would be useful as I don't have much experience in using webpacker.
ruby-on-rails reactjs typescript webpack production-environment
ruby-on-rails reactjs typescript webpack production-environment
asked Nov 14 '18 at 15:45
GumarovRinatGumarovRinat
12
12
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
you need to add in your webpacker.yml
check_yarn_integrity: false
New contributor
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53303940%2frun-rails-react-with-webpacker-in-production-mode-assetsprecompile-takes-very%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
you need to add in your webpacker.yml
check_yarn_integrity: false
New contributor
add a comment |
you need to add in your webpacker.yml
check_yarn_integrity: false
New contributor
add a comment |
you need to add in your webpacker.yml
check_yarn_integrity: false
New contributor
you need to add in your webpacker.yml
check_yarn_integrity: false
New contributor
New contributor
answered Feb 4 at 18:16
Тарас ВеселыйТарас Веселый
12
12
New contributor
New contributor
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53303940%2frun-rails-react-with-webpacker-in-production-mode-assetsprecompile-takes-very%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown