theme-next / hexo-filter-optimize

A Hexo plugin that optimize the pages loading speed.
MIT License
47 stars 2 forks source link

the icons are gone? #2

Closed sli1989 closed 6 years ago

sli1989 commented 6 years ago

is it right?

filter_optimize:
  enable: true
  # remove static resource query string
  #   - like `?v=1.0.0`
  remove_query_string: true
  # remove the surrounding comments in each of the bundled files
  remove_comments: false
  css:
    enable: true
    # bundle loaded css file into the one
    bundle: true
    # use a script block to load css elements dynamically
    delivery: true
    # make specific css content inline into the html page
    #   - only support the full path
    #   - default is ['css/main.css']
    inlines:
    excludes:
  js:
    # bundle loaded js file into the one
    bundle: true
    excludes:

and then hexo clean && hexo g && hexo s _20180125153445

tsanie commented 6 years ago

Yeah, it's an issue when you use the internal font-awesome library instead of the CDN.

Now the plugin will bundle the /lib/font-awesome/css/font-awesome.css into the /style.css, so its font-src will lead a wrong path, that couldn't find it. (the font-src's result is now /fonts/fontawesome-webfont.woff2, and not the right path /lib/font-awesome/fonts/fontawesome-webfont.woff2) image

There is now 3 ways to resolve it.

  1. change the NexT's config to use the CDN font-awesome.
  2. or add the **/font-awesome.min.css to the config.filter_optimize.css.excludes, like:
    filter_optimize:
    ...
    css:
    ...
    excludes:
      - '**/font-awesome.min.css'
  3. or modify the font-awesome.min.css, replace the all ../fonts/ with lib/font-awesome/fonts/

Personally, I suggest DO NOT use the second one. Because it will not make the font-awesome.min.css to load asynchronously.


And if you bundle any css referencing other files within relative paths probably would get the same errors. It seems doesn't have a good way to automatically solve these problems, I think I need help to deal with it. 😕

sli1989 commented 6 years ago

thanks, it's solved. but it seems to take longer time to hexo g?

tsanie commented 6 years ago

Yes, it will take longer time to filter files. Such as it will synchronized bundling files by their sort. And I'm trying to optimize it by using a async way and keep the right orders in the meantimes.

sli1989 commented 6 years ago

I have added addition css file (H5 palyer) in my blog, but they are gone. is there any way to load them such add them to whitelist?

tsanie commented 6 years ago

@sli1989 Normally, it will be bundled into the public/style.css, is there a live demo site that is used the plugin and had questions? I saw your blog seems no problem.

And if you want some files would NOT be bundled into the style.css, you can just add them to the parameter excludes. (it means not process the files, and keep them loaded as their before)

sli1989 commented 6 years ago

OK, thanks. the deployed blog haven't used the hexo-filter-optimize.