我正在尝试在 Jekyll 项目中配置 jQuery。我在引用我的脚本标签时遇到问题(如果我包含 CDN 就可以了)。
我正在阅读一些 github-pages 可能无法处理您的 node_modules 的问题。但是,我只是在本地工作,运气不佳。
js 文件的加载方式是否会在 sass:
> load_paths:
下以不同的方式加载?有关系吗? (Sass 文件工作正常,但没有 js 文件工作)
_config.yml
sass:
load_paths:
- _sass
- node_modules/
我的页脚:
<script src="{{'/node_modules/jquery/dist/jquery.min.js' | prepend: site.baseurl}}"></script>
错误:
[2019-03-27 12:44:36] ERROR `/node_modules/jquery/dist/jquery.min.js' not found.
最佳答案
有同样的问题。对我来说,在 _config.yml 中添加以下内容有帮助:
include : [".htaccess", "node_modules"]
exclude : ["Gemfile", "Gemfile.lock", "vendor/bundle/", "vendor/cache/", "vendor/gems/", "vendor/ruby/"]
似乎仅仅从排除中删除“node_modules”并没有帮助,您必须明确地将其添加到包含中。
关于javascript - 使用 load_paths 时未找到 Jekyll node_modules,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55382615/