使用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
我正在添加此答案,以便对其他用户有所帮助。
如果不想在不重新加载浏览器的情况下更新js文件,请关闭hmr设置。
hmr: false
在RAILS中,webpacker.yml
具有不同的设置,其中之一是hmr
,它是热模块替换,这是一种Webpack功能,可在不重新加载浏览器的情况下更新Javascript。热模块替换中的“模块”仅指每个Javascript源代码文件。为了进行这些更新,Webpack将HMR运行时安装到您的输出包中。
有关HMR- CHECK THIS的更多详细信息