digitalsparky / jekyll-minifier

Jekyll HTML/XML/CSS/JS Minifier utilising yui-compressor, and htmlcompressor
GNU General Public License v3.0
245 stars 25 forks source link

Unexpected token: Operator (<) errors with javascript compression #51

Open Gizmokid2005 opened 4 years ago

Gizmokid2005 commented 4 years ago

This may be related to #22 but I've done a bit of digging and figured I'd throw it into its own issue. Please close/reassign as needed.

I've been trying to get this plugin to work with jekyll for a few hours now and have been able to track down the issue to something with compressing javascript, and subsequently with the exclusion not working. (As a note, this has taken a while as it appears that #33 is still present.)

I should note this only happens for production builds JEKYLL_ENV=production be jekyll b (with and without --watch or --incremental).

I've already gone through and made sure to enable harmony:

uglifier_args:
  harmony: true

If I run with compress_javascript: false the compression works just fine, however as soon as I allow for javascript to be compressed, I get the following error, with everything up to date as of today. jekyll 3.8.6 | Error: Unexpected token: operator (<) There is no other information provided with this error. I'm currently only using the bootstrap.bundle.js, query-3.3.1.slim.min.js and respond.js for javascript files. I even tried to exclude all of them using an exclude for each file individually and the error seems to still happen, so it would appear that something is broken with the exclude or just in javascript processing in general currently.

I've tried excluding in both the following ways:

#With and without quoted strings
  exclude:
  - jquery-3.3.1.slim.min.js
  - bootstrap.bundle.js
  - bootstrap.bundle.js.map
  - bootstrap.bundle.min.js
  - bootstrap.bundle.min.js.map
  - respond.js
  exclude: ['jquery-3.3.1.slim.min.js','bootstrap.bundle.js','bootstrap.bundle.js.map','bootstrap.bundle.min.js','bootstrap.bundle.min.js.map','respond.js']

Ruby 2.6.3 The gems in this particular bundle are:

  * addressable (2.6.0)
  * bundler (1.17.2)
  * colorator (1.1.0)
  * concurrent-ruby (1.1.5)
  * cssminify2 (2.0.1)
  * em-websocket (0.5.1)
  * eventmachine (1.2.7)
  * execjs (2.7.0)
  * fastercsv (1.5.5)
  * ffi (1.11.1)
  * forwardable-extended (2.6.0)
  * htmlcompressor (0.4.0)
  * http_parser.rb (0.6.0)
  * i18n (0.9.5)
  * jekyll (3.8.6)
  * jekyll-feed (0.12.1)
  * jekyll-import (0.19.0)
  * jekyll-minifier (0.1.10)
  * jekyll-paginate (1.1.0)
  * jekyll-sass-converter (1.5.2)
  * jekyll-seo-tag (2.6.1)
  * jekyll-watch (2.2.1)
  * jekyll_inline_highlight (3.0)
  * json (2.2.0)
  * json-minify (0.0.3)
  * kramdown (1.17.0)
  * liquid (4.0.3)
  * listen (3.1.5)
  * mercenary (0.3.6)
  * mini_portile2 (2.4.0)
  * nokogiri (1.10.3)
  * pathutil (0.16.2)
  * public_suffix (3.1.1)
  * rb-fsevent (0.10.3)
  * rb-inotify (0.10.0)
  * reverse_markdown (1.1.0)
  * rouge (3.8.0)
  * ruby_dep (1.5.0)
  * safe_yaml (1.0.5)
  * sass (3.7.4)
  * sass-listen (4.0.0)
  * uglifier (4.1.20)

And _config.yml settings:

defaults:
  - scope:
      path: "_pages"
    values:
      permalink: /:basename/
      layout: "default"

# Build settings
markdown: kramdown
highlighter: rouge
plugins:
  - jekyll-feed
  - jekyll-seo-tag
  - jekyll_inline_highlight
  - jekyll-minifier
include: ['_pages','.htaccess']
exclude: ['updatesite.sh']
sass:
  style: compressed
strict_front_matter: true
keep_files:
  - icon
  - stats
  - awstatsicons
  - awstats-icon
  - temp
  - video
  - keybase.txt

permalink: /:year/:month/:title
excerpt_separator: <!--more-->
paginate: 15
jekyll-minifier:
#  compress_javascript: false
#  exclude: ['jquery-3.3.1.slim.min.js','bootstrap.bundle.js','bootstrap.bundle.js.map','bootstrap.bundle.min.js','bootstrap.bundle.min.js.map','respond.js']
  exclude:
  - 'jquery-3.3.1.slim.min.js'
  - 'bootstrap.bundle.js'
  - 'bootstrap.bundle.js.map'
  - 'bootstrap.bundle.min.js'
  - 'bootstrap.bundle.min.js.map'
  - 'respond.js'
  uglifier_args:
    harmony: true
FarazzShaikh commented 3 years ago

Did you ever find a fix? Encountering a similar problem

Gizmokid2005 commented 3 years ago

I haven't found a fix yet, but I haven't really been looking either, I just stopped using the javascript compression to get around it for now. The site still loads well within my desires for speed so it's not a big issue, but it would be nice to be fixed.

This would be nice to be fixed though.