gpt4 book ai didi

ruby-on-rails - 如何在 Rails Webpacker 中添加多个 source_path

转载 作者:行者123 更新时间:2023-12-04 11:16:56 25 4
gpt4 key购买 nike

我们正在使用 Webpacker用于装载 JavaScriptsCSS文件进入网页。
目前,在 webpacker.yml我们已经设置了 source_pathapp/javascript .从这个目录加载 JavaScript 文件工作正常。
但是在我们的应用程序中,我们有一个 engines目录,以及所有 JavaScript文件位于不同的 enginesengines目录,为了加载这些 JavaScript 文件,我们创建了一个 linkapp/javascript/packs引擎目录中的每个包。
有没有更好的方法来做到这一点,而无需提供链接 通过提供多个 source_pathwebpacker.yml文件。

以供引用:

This is the folder structure currently we have:

-root
|
|-app
|-javascript
|-packs
|-[link to engine1.js pack files]
|-[link to engine2.js pack files]
|-engines
|- engine1
|-app
|-javascript
|-packs
|-engine1.js
|- engine2
|-app
|-javascript
|-packs
|-engine1.js

And this is how the webpacker.yml configuration

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: ['app/assets']

最佳答案

我想你会想做这样的事情:

additional_paths: ['engines']
来源: https://github.com/rails/webpacker#resolved

If you are adding Webpacker to an existing app that has most of the assets inside app/assets or inside an engine, and you want to share that with webpack modules, you can use the additional_paths option available in config/webpacker.yml. This lets you add additional paths that webpack should lookup when resolving modules:

关于ruby-on-rails - 如何在 Rails Webpacker 中添加多个 source_path,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50982724/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com