【发布时间】:2020-02-29 20:53:20
【问题描述】:
使用 Rails / Webpacker 编译资产。
Webpacker 开始变得非常慢(编译时间为 3 分钟)。我注意到public/assets 文件夹中充满了指纹资产,例如..
application-1e69eb85a81f4a963fde.js
application-828cf61e1e6dc295ffee.js
application-95ba1bc02eaf571bca3d.js
每次页面刷新都会创建新的。
我正在开发模式下启动服务器,我不确定为什么每次刷新都会产生新的指纹资产。但我的猜测是这就是导致问题的原因。
有人经历过吗?
webpack.yml
# Note: You must restart bin/webpack-dev-server for changes to take effect
default: &default
source_path: client
source_entry_path: bundles
public_output_path: assets/bundles # outputs to => public/assets/bundles
cache_path: tmp/cache/webpacker
cache_manifest: false
extensions:
- .jsx
- .js
- es6.js
- .sass
- .scss
- .worker
- .worker.js
- .css
- .module.sass
- .module.scss
- .module.css
- .png
- .svg
- .gif
- .jpeg
- .jpg
- .eot
- .svg
- .ttf
- .woff
development:
<<: *default
compile: true
# Reference: https://webpack.js.org/configuration/dev-server/
dev_server:
https: false
host: localhost
port: 3035
public: localhost:3035
hmr: true
# Inline should be set to true if using HMR
inline: true
overlay: true
compress: true
disable_host_check: true
use_local_ip: false
quiet: false
headers:
'Access-Control-Allow-Origin': '*'
watch_options:
ignored: /node_modules/
test:
<<: *default
compile: true
# Compile test bundles to a separate directory
public_output_path: bundles-test
production:
<<: *default
# Production depends on precompilation of packs prior to booting for performance.
compile: false
# Cache manifest.json for performance
cache_manifest: true
【问题讨论】:
-
可以分享一下 webpacker.yml 文件吗?
-
刚刚更新的问题
-
你能把hmr设为false然后试试吗?
-
是的,有效。谢谢
标签: ruby-on-rails ruby-on-rails-6 webpacker