Запустить rails-реакцию с webpacker в рабочем режиме.активы: прекомпиляция занимает очень много времени - PullRequest
0 голосов
/ 14 ноября 2018

У меня есть проект по рельсам - реагируем с веб-упаковщиком. Он отлично работает в режиме разработки, но я не могу запустить его в рабочем режиме.

Я запускаю его внутри контейнера докера:

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

Вот мой config/environments/production.rb файл

  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

Когда я пытаюсь запустить rails assets:precompile на моей локальной машине, это занимает около 1 часа, и ничего не происходит. И когда я пытаюсь запустить Docker, он говорит, что Your Yarn packages are out of date! И предлагает сделать установку пряжи. Я даже попробовал это с удалением файла yarn.lock.

Ниже мой конфиг webpacker.yml:

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

Любая помощь будет полезна, поскольку у меня нет большого опыта использования веб-упаковщика.

1 Ответ

0 голосов
/ 04 февраля 2019

нужно добавить в свой webpacker.yml

check_yarn_integrity: false
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...