我正在研究如何使Jekyll (v4.0.0)最小化javascript。我已经安装了jekyll-assets (v3.0.12)和jekyll-小型机(v0.1.10),但到目前为止还没有成功.javascript仍然没有缩小。
我在_config.yml中尝试了一些没有帮助的配置选项,在这里引用了文档:
https://github.com/envygeeks/jekyll-assets/tree/v3.0-current#configuration
任何帮助都将不胜感激!
Gemfile
# frozen_string_literal: true
source "https://rubygems.org"
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
# gem "rails"
gem "jekyll", "~> 4.0"
group :jekyll_plugins do
gem "jekyll-assets"
gem "jekyll-minifier"
end_config.yml
permalink: pretty
sass:
style: compressed
exclude:
- gulpfile.js
- node_modules
- CNAME
- README
- '*.json'
- .DS_Store
plugins:
- jekyll-assets
- jekyll-minifier
assets:
sources:
- "css"
- "js"_includes/scripts.html
...
{% javascript app %}
...js/app.js
//=require scripts.js
//=require scripts-2.js
var myStr = "app";
myStr += " js";
console.log(myStr);命令行
JEKYLL_ENV=production bundle exec jekyll build发布于 2020-06-19 21:00:42
Jekyll创建静态站点后,Jekyll-Minifier插件可能正在缩小_site目录中的javascript。如果您正在使用github页面,这将无法工作,因为Github是从源代码构建的,并且插件支持有限。您可能需要使用插件进行构建,并使用_site目录手动提供服务,或者找到一个不同的插件,使其最小化,而不是在_site目录中。
https://stackoverflow.com/questions/59725053
复制相似问题