next-theme / hexo-optimize

🚩 A Hexo plugin that optimize the pages loading speed, written in Rust
MIT License
13 stars 2 forks source link

delivery.some is not a function #23

Closed iml885203 closed 1 year ago

iml885203 commented 1 year ago

I got this error when upgrading hexo-optimize to ^3.2.0.

TypeError: delivery.some is not a function
    at /Users/logan/Logan/blog-source/node_modules/hexo-optimize/lib/filter.js:29:18
    at String.replace (<anonymous>)
    at minify (/Users/logan/Logan/blog-source/node_modules/hexo-optimize/lib/filter.js:11:13)
    at /Users/logan/Logan/blog-source/node_modules/hexo-optimize/lib/filter.js:103:11
error Command failed with exit code 2.

config:

filter_optimize:
  enable: true
  # static resource versioning
  versioning: false
  css:
    # minify all css files
    minify: true
    # bundle loaded css files into one
    bundle: false
    # use a script block to load css elements dynamically
    delivery: false
    # make specific css content inline into the html page
    #   - only support the full path
    #   - default is ['css/main.css']
    inlines:
      # support full path only
      - css/main.css
    excludes:
  js:
    # minify all js files
    minify: true
    # bundle loaded js files into one
    bundle: true
    excludes:
    # remove the comments in each of the js files
    remove_comments: false
  html:
    # minify all html files
    minify: true
    excludes:
  # set the priority of this plugin,
  # lower means it will be executed first, default of Hexo is 10
  priority: 12
stevenjoezhang commented 1 year ago

You can leave delivery option empty:

-delivery: false
+delivery: 
iml885203 commented 1 year ago

It doesn't work, I got another error.

ERROR Plugin load failed: hexo-optimize
TypeError: Cannot read properties of null (reading 'length')
    at /Users/logan/Logan/blog-source/node_modules/hexo-optimize/index.js:41:27
    at /Users/logan/Logan/blog-source/node_modules/hexo/lib/hexo/index.js:305:14
    at tryCatcher (/Users/logan/Logan/blog-source/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/logan/Logan/blog-source/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/Users/logan/Logan/blog-source/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromise0 (/Users/logan/Logan/blog-source/node_modules/bluebird/js/release/promise.js:649:10)
    at Promise._settlePromises (/Users/logan/Logan/blog-source/node_modules/bluebird/js/release/promise.js:729:18)
    at _drainQueueStep (/Users/logan/Logan/blog-source/node_modules/bluebird/js/release/async.js:93:12)
    at _drainQueue (/Users/logan/Logan/blog-source/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/Users/logan/Logan/blog-source/node_modules/bluebird/js/release/async.js:102:5)
    at Immediate.Async.drainQueues [as _onImmediate] (/Users/logan/Logan/blog-source/node_modules/bluebird/js/release/async.js:15:14)
    at processImmediate (node:internal/timers:466:21)
stevenjoezhang commented 1 year ago

Ok, you can try to remove this line completely, it should work now

-delivery: false
iml885203 commented 1 year ago

It worked. Thanks for your help.