Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Javascript Changes Not being applied #874

Closed
2 tasks
DaveBben opened this issue Feb 26, 2017 · 12 comments
Closed
2 tasks

Javascript Changes Not being applied #874

DaveBben opened this issue Feb 26, 2017 · 12 comments

Comments

@DaveBben
Copy link

  • This is a question about using the theme.
  • [x ] I believe this to be a bug with the theme --- not Jekyll, GitHub Pages or one of the bundled plugins.
  • This is a feature request.
  • [ x] I have updated all gems with bundle update.
  • [x ] I have tested locally with bundle exec jekyll build.

Environment informations

**Minimal Mistakes version:4.2.2
**github-pages or jekyll gem version:3.4.0
**Operating system: Ubuntu 16.04


Expected behavior

When I make a changes to _main.js, then rebuid using npm, the changes are applied and in the _main.min.js file. However, when I build the site, the _main.min.js file remains unaltered.

Steps to reproduce the behavior

First

I delete the following from main.js
// Follow menu drop down $(".author__urls-wrapper button").on("click", function() { $(".author__urls").fadeToggle("fast", function() {}); $(".author__urls-wrapper button").toggleClass("open"); });

The I run npm run build:js

The main.min.js file is produced and does not contain the deleted code.
FInally I run:

bundle exec jekyll build

In the Site folder, the main.min.js file still contains the deleted code as well as main.js file.
I've also tried with

bundle exec jekyll build --incremental

and the same output occures.

@mmistakes
Copy link
Owner

Smells like a Jekyll issue and not the theme. If the script is updated after you run build:js then perhaps it's a caching issue. Have you tried running jekyll clean to wipe all your caches and the _site folder?

Other than that I'm out of ideas. Theme files all sounds right, something is going on with Jekyll during the build. Could be some sort of bug you're encountering. Gem theme or is it a fork of the repo?

@DaveBben
Copy link
Author

I'm using the Gem theme. Yeah, it might be a Jekyll issue then I have no idea. So far, I've tried the following:

  1. Uninstalling and reinstalling Jekyll and all the dependencies
    2 . Clearing the cache for node js
  2. Using the comman npm run watch:js and npm run build:js
  3. Using bundle exec jekyll buid --watch

The thing is, I see the change is happening within the development folders. Both the main.js and main.min.js have been changed. But for some reason, the files in the site folder all contain the old unmodified code.

Just to make sure I'm not missing something, here is my gemfile and includes and excludes
source "https://rubygems.org"

gem "jekyll", "~> 3.4.0"
gem "minimal-mistakes-jekyll"
gem 'jekyll-admin', group: :jekyll_plugins

Includes and excludes in _config.yml

Reading Files

include:

  • .htaccess
  • _pages

exclude:

  • "*.sublime-project"
  • "*.sublime-workspace"
  • vendor
  • .asset-cache
  • .bundle
  • .jekyll-assets-cache
  • .sass-cache
  • assets/js/plugins
  • assets/js/_main.js
  • assets/js/vendor
  • Capfile
  • CHANGELOG
  • config
  • Gemfile
  • Gruntfile.js
  • gulpfile.js
  • LICENSE
  • log
  • node_modules
  • package.json
  • Rakefile
  • README
  • tmp
  • /docs # ignore Minimal Mistakes /docs
  • /test # ignore Minimal Mistakes /test
    keep_files:
  • .git
  • .svn

@mmistakes
Copy link
Owner

mmistakes commented Feb 26, 2017

It is indeed a Jekyll issue. This same exact problem came up before and filed a ticket, forgot all about that.

jekyll/jekyll#5676

Not sure if or when there will be a fix. The problem is Jekyll will only override theme gem assets that have YAML Front Matter, like /assets/css/main.scss. That's why it's ignoring your modified JS files on build.

@mmistakes
Copy link
Owner

Closing as this an upstream issue with Jekyll.
Related #722

mmistakes added a commit that referenced this issue Feb 28, 2017
- Add `---` YAML Front Matter as a workaround to allow the theme gem's version to be overridden locally.
- Adjust page scope in Front Matter default to avoid adding a layout to `main.min.js`
- Fixes #874, Fixes #722
mmistakes added a commit that referenced this issue Feb 28, 2017
- Add `---` YAML Front Matter as a workaround to allow the theme gem's version to be overridden locally.
- Adjust page scope in Front Matter default to avoid adding a layout to `main.min.js`
- Fixes #874, Fixes #722
@mmistakes
Copy link
Owner

@DaveBben I found a workaround until this is fixed upstream. If I add YAML Front Matter to main.min.js it can be overridden. In the next release of MM I'll push it out. All you'll have to do is add:

---
---

to the top of your modified /assets/js/main.min.js file and it should override the theme gem's version.

@DaveBben
Copy link
Author

Oh wow you're awesome! Thanks, that would be so helpful. Hoepfully they'll get the Jekyll issued fixed at some point.

@mmistakes
Copy link
Owner

Hopefully that's soon, think I saw it was slated for Jekyll 3.5.

Just pushed an update to MM. Run bundle update and you should get version 4.3.0. Let me know how it works out.

@DaveBben
Copy link
Author

DaveBben commented Mar 1, 2017

Yess! It works perfectly! The javascript file now reflects the changes. Thanks for all of your help.

@mmistakes
Copy link
Owner

Fantastic! Thanks for checking.

kkunapuli pushed a commit to kkunapuli/kkunapuli.github.io that referenced this issue May 30, 2019
- Add `---` YAML Front Matter as a workaround to allow the theme gem's version to be overridden locally.
- Adjust page scope in Front Matter default to avoid adding a layout to `main.min.js`
- Fixes mmistakes#874, Fixes mmistakes#722
@Harrypotterrrr
Copy link

@mmistakes Sorry for my simple question..
I met the same problem and append YAML Front Matter to /asset/main.min.js but it still doesn't change after run 'bundle exec jekyll serve Could you tell me what the difference is between/asset/_main.jsand/asset/main.min.js? I want to only write code in_main.js, so I wonder if /asset/main.min.js` is updated automatically.

@mmistakes
Copy link
Owner

@Harrypotterrrr /assets/js/_main.js is the source JavaScript that is combined with some other scripts like jQuery and plugins, then minified into main.min.js. This is the file the theme uses.

So if you make changes to _main.js you will need to run the build script as described in the theme's documentation. This will create the main.min.js file with any changes you've made.

@Harrypotterrrr
Copy link

wow, Appreciate your help!

makaroniame added a commit to makaroniame/makaroniame-old.github.io that referenced this issue May 18, 2022
- Add `---` YAML Front Matter as a workaround to allow the theme gem's version to be overridden locally.
- Adjust page scope in Front Matter default to avoid adding a layout to `main.min.js`
- Fixes mmistakes#874, Fixes mmistakes#722
jchwenger pushed a commit to jchwenger/jchwenger.github.io that referenced this issue May 5, 2023
- Add `---` YAML Front Matter as a workaround to allow the theme gem's version to be overridden locally.
- Adjust page scope in Front Matter default to avoid adding a layout to `main.min.js`
- Fixes mmistakes#874, Fixes mmistakes#722
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants