与webpacker我有一个项目,轨反应。它完美的发展模式,但我不能在生产模式下运行它。
我搬运工容器内运行:
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
需要abouut 1小时,没有任何反应。当我尝试运行泊坞窗,它说,Your Yarn packages are out of date!
,并建议做纱线安装。我甚至有消除yarn.lock文件tryed这一点。
下面是我的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
因为我没有使用webpacker多少经验任何帮助将是有益的。
你需要在你的webpacker.yml添加
check_yarn_integrity: false