【发布时间】:2020-10-15 01:01:38
【问题描述】:
我将 webpacker 从 4.x 升级到 5.2.1 并开始收到以下警告:
The resolved_paths option has been deprecated. Use additional_paths instead.
这看起来很简单,我的config/webpacker.yml 几乎没有修改:
# Additional paths webpack should lookup modules
# ['app/assets', 'engine/foo/app/assets']
resolved_paths: [
'app/assets',
]
但是在那里做一个简单的s/resolved_paths/additional_paths/ 是行不通的:
[Webpacker] Compiling...
[Webpacker] Compilation failed:
Hash: 7448f36a43523a84e146
Version: webpack 4.44.1
Time: 5803ms
Built at: 10/15/2020 11:57:06 AM
Asset Size Chunks Chunk Names
js/application-a019b363e4513fe092e6.js 3.02 MiB application [emitted] [immutable] application
js/application-a019b363e4513fe092e6.js.map 3.03 MiB application [emitted] [dev] application
js/hello_react-40e806bdb6de496532d8.js 1.05 MiB hello_react [emitted] [immutable] hello_react
js/hello_react-40e806bdb6de496532d8.js.map 1.21 MiB hello_react [emitted] [dev] hello_react
js/server_rendering-9cd9dcc6e1cebb2a8063.js 2.25 MiB server_rendering [emitted] [immutable] server_rendering
js/server_rendering-9cd9dcc6e1cebb2a8063.js.map 2.44 MiB server_rendering [emitted] [dev] server_rendering
manifest.json 1.05 KiB [emitted]
Entrypoint application = js/application-a019b363e4513fe092e6.js js/application-a019b363e4513fe092e6.js.map
Entrypoint hello_react = js/hello_react-40e806bdb6de496532d8.js js/hello_react-40e806bdb6de496532d8.js.map
Entrypoint server_rendering = js/server_rendering-9cd9dcc6e1cebb2a8063.js js/server_rendering-9cd9dcc6e1cebb2a8063.js.map
[./app/javascript/channels sync recursive _channel\.js$] ./app/javascript/channels sync _channel\.js$ 160 bytes {application} [built]
[./app/javascript/channels/index.js] 211 bytes {application} [built]
[./app/javascript/components sync recursive ^\.\/.*$] ./app/javascript/components sync ^\.\/.*$ 2.42 KiB {application} {server_rendering} [built]
[./app/javascript/packs/application.js] 10.3 KiB {application} [built]
[./app/javascript/packs/hello_react.jsx] 1.05 KiB {hello_react} [built]
[./app/javascript/packs/server_rendering.js] 301 bytes {server_rendering} [built]
[./node_modules/webpack/buildin/amd-options.js] (webpack)/buildin/amd-options.js 80 bytes {application} {server_rendering} [built]
[./node_modules/webpack/buildin/global.js] (webpack)/buildin/global.js 905 bytes {application} {server_rendering} [built]
[./node_modules/webpack/buildin/module.js] (webpack)/buildin/module.js 552 bytes {application} {server_rendering} [built]
+ 474 hidden modules
ERROR in ./app/javascript/components/menu/MenuComponent.jsx
Module not found: Error: Can't resolve 'images/ellipsis-v.svg' in '/home/me/app/javascript/components/menu'
所以很明显additional_paths 不仅仅是一个替代品,尽管文档建议它应该是。
在我跳入源代码试图了解这里发生了什么之前,有人快速解决了吗?
【问题讨论】:
-
现在遇到这个问题,你解决了吗?
-
@OmarHussein 尚未找到修复程序,它不会影响功能,所以我只是照常进行,但这很烦人。
-
这里是变化的来源——看起来不同之处在于它处理通配符的方式。但这对你和我意味着什么,我还不确定。 github.com/rails/webpacker/commit/…
-
根据github.com/rails/webpacker/issues/2705,您可能还需要更新您的 gem 才能使其正常工作
-
感谢@compiledweird,非常有趣 - 我今天会在我们的代码库中查看它。