使用 Docker 和 Docker Compose,升级到 webpacker 3.3.0 后,我无法启动并运行 webpacker 服务。之后的输出docker-compose up
是:
webpack dev_server configuration not found in /app/config/webpacker.yml.
Please run bundle exec rails webpacker:install to install Webpacker
我已经运行webpacker:install
了 - 它进行了更改,但输出是相同的。我还运行rails new test --webpacker
并比较了配置文件。到目前为止,工作生成的应用程序和我自己的应用程序之间唯一显着的区别是 Node 版本。在典型 RVM 环境中的本地计算机上,节点版本为v9.4.0
,在 docker 映像中为v8.9.3
. 两种环境中的纱线都是1.3.2
.
我的 config/webpacker.yml 和生成的几乎一模一样。唯一的区别是添加了一些扩展:
# Note: You must restart bin/webpack-dev-server for changes to take effect
default: &default
source_path: app/javascript
source_entry_path: packs
public_output_path: packs
cache_path: tmp/cache/webpacker
# Additional paths webpack should lookup modules
# ['app/assets', 'engine/foo/app/assets']
resolved_paths: []
# Reload manifest.json on all requests so we reload latest compiled packs
cache_manifest: false
extensions:
- .coffee
- .erb
- .js
- .jsx
- .ts
- .vue
- .sass
- .scss
- .css
- .module.sass
- .module.scss
- .module.css
- .png
- .svg
- .gif
- .jpeg
- .jpg
development:
<<: *default
compile: true
# Reference: https://webpack.js.org/configuration/dev-server/
dev_server:
https: false
host: localhost
port: 3035
public: localhost:3035
hmr: false
# 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 packs to a separate directory
public_output_path: packs-test
production:
<<: *default
# Production depends on precompilation of packs prior to booting for performance.
compile: false
# Cache manifest.json for performance
cache_manifest: true
配置/webpack/environment.js:
const { environment } = require('@rails/webpacker')
module.exports = environment
配置/webpack/development.js:
const environment = require('./environment')
module.exports = environment.toWebpackConfig()
关于为什么找不到 dev_server 配置的任何想法?我不相信节点版本是原因。