hexojs / hexo

A fast, simple & powerful blog framework, powered by Node.js.
https://hexo.io
MIT License
39.43k stars 4.85k forks source link

hexo.route.set() doesn't apply to theme's assets #3529

Closed curbengh closed 5 years ago

curbengh commented 5 years ago

Environment Info

Node version(node -v): v11.14.0

Your site _config.yml (Optional):

neat_enable: true

Your package.json package.json:

  "dependencies": {
    "hexo": "^3.8.0",
    "hexo-generator-archive": "^0.1.5",
    "hexo-generator-category": "^0.1.3",
    "hexo-generator-feed": "^1.2.2",
    "hexo-generator-index": "^0.2.1",
    "hexo-generator-json-content": "^4.1.3",
    "hexo-generator-tag": "^0.2.0",
    "hexo-renderer-ejs": "^0.3.1",
    "hexo-renderer-marked": "^0.3.2",
    "hexo-renderer-stylus": "^0.3.3",
    "hexo-server": "^0.3.3",
    "hexo-yam": "git://github.com/weyusi/hexo-yam.git#file-ext"
  }

For question

I wrote hexo-yam plugin to pre-compress assets. I want to add a feature which allows user to set custom file extensions.

Currently the file extensions are hard-coded which is not ideal. https://github.com/weyusi/hexo-yam/blob/3aa5143adff094e9a44f631d94f2eb9cb8cddd46/lib/filter.js#L105

However, after introducing that feature, https://github.com/weyusi/hexo-yam/blob/62af5751f298953cbadf3ba16a1a7a699c52e8da/lib/filter.js#L109-L131 theme's compressed assets (css and js in .gz) are not in the public folder anymore.

From the output of hexo g, *.css.gz and *.js.gz are not shown on the Generated:, but they do show up on my plugin's log. So, those assets definitely went through the compression, but somehow couldn't be saved into .gz files.

Is there any way I can debug (callback?) the hexo.route.set()?

$ hexo generate
INFO  Start processing
INFO  Path css/donate.css
INFO  Path css/typing.css
INFO  Path images/alipay.svg
INFO  Path images/bitcoin.svg
INFO  Path images/download.png
INFO  Path images/github.svg
INFO  Path images/like.svg
INFO  Path images/new-file.txt
INFO  Path images/paypal.svg
INFO  Path images/wechat.svg
INFO  Path js/clipboard.min.js
INFO  Path js/sri.min.js
INFO  Path js/typing.js
INFO  Path js/jquery.min.js
INFO  Path atom.xml
INFO  Path content.json
INFO  Path 2018/11/01/test-post/index.html
INFO  Path 2018/10/30/updated-date/index.html
INFO  Path 2018/10/15/old-post/index.html
INFO  Path 2018/10/06/fancybox-test/index.html
INFO  Path 2018/10/05/hello-world/index.html
INFO  Path archives/index.html
INFO  Path archives/2018/index.html
INFO  Path archives/2018/10/index.html
INFO  Path archives/2018/11/index.html
INFO  Path index.html
INFO  Files loaded in 1 s
INFO  Gzip-compressed atom.xml [73.31% saved]
INFO  Gzip-compressed content.json [66.14% saved]
INFO  Gzip-compressed 2018/11/01/test-post/index.html [68.83% saved]
INFO  Gzip-compressed 2018/10/30/updated-date/index.html [69.04% saved]
INFO  Gzip-compressed 2018/10/05/hello-world/index.html [70.66% saved]
INFO  Gzip-compressed archives/index.html [73.73% saved]
INFO  Gzip-compressed archives/2018/index.html [73.78% saved]
INFO  Gzip-compressed archives/2018/10/index.html [72.31% saved]
INFO  Gzip-compressed archives/2018/11/index.html [66.42% saved]
INFO  Gzip-compressed index.html [66.32% saved]
INFO  Gzip-compressed 2018/10/06/fancybox-test/index.html [69.13% saved]
INFO  Gzip-compressed 2018/10/15/old-post/index.html [67.78% saved]
INFO  Gzip-compressed images/alipay.svg [55.30% saved]
INFO  Gzip-compressed images/bitcoin.svg [58.67% saved]
INFO  Gzip-compressed images/github.svg [54.54% saved]
INFO  Gzip-compressed images/new-file.txt [31.30% saved]
INFO  Gzip-compressed images/like.svg [53.55% saved]
INFO  Gzip-compressed images/paypal.svg [54.29% saved]
INFO  Gzip-compressed images/wechat.svg [53.48% saved]
INFO  Gzip-compressed css/donate.css [71.01% saved]
INFO  Gzip-compressed js/sri.min.js [49.03% saved]
INFO  Gzip-compressed js/typing.js [59.37% saved]
INFO  Gzip-compressed js/clipboard.min.js [67.02% saved]
INFO  Gzip-compressed css/typing.css [71.99% saved]
INFO  Generated: atom.xml
INFO  Generated: content.json
INFO  Generated: atom.xml.gz
INFO  Generated: content.json.gz
INFO  Generated: index.html.gz
INFO  Generated: index.html
INFO  Generated: archives/index.html.gz
INFO  Generated: archives/index.html
INFO  Generated: archives/2018/index.html
INFO  Generated: archives/2018/10/index.html.gz
INFO  Generated: images/alipay.svg
INFO  Generated: archives/2018/11/index.html.gz
INFO  Generated: images/github.svg
INFO  Generated: images/like.svg
INFO  Generated: images/new-file.txt
INFO  Generated: images/paypal.svg
INFO  Generated: images/wechat.svg
INFO  Generated: images/download.png
INFO  Generated: archives/2018/index.html.gz
INFO  Generated: images/bitcoin.svg
INFO  Generated: archives/2018/10/index.html
INFO  Generated: archives/2018/11/index.html
INFO  Generated: css/donate.css
INFO  Generated: js/sri.min.js
INFO  Generated: js/typing.js
INFO  Generated: css/typing.css
INFO  Generated: js/clipboard.min.js
INFO  Generated: 2018/11/01/test-post/index.html.gz
INFO  Generated: 2018/10/15/old-post/index.html.gz
INFO  Generated: 2018/10/05/hello-world/index.html.gz
INFO  Generated: 2018/10/06/fancybox-test/index.html.gz
INFO  Generated: 2018/10/30/updated-date/index.html.gz
INFO  Generated: 2018/11/01/test-post/index.html
INFO  Generated: 2018/10/30/updated-date/index.html
INFO  Generated: 2018/10/15/old-post/index.html
INFO  Generated: 2018/10/06/fancybox-test/index.html
INFO  Generated: 2018/10/05/hello-world/index.html
INFO  Gzip-compressed js/jquery.min.js [61.40% saved]
INFO  Generated: js/jquery.min.js
INFO  38 files generated in 727 ms
curbengh commented 5 years ago

Resolved using nanomatch