hexojs / hexo

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

`hexo server` doesn't recompile helper file #3724

Open DreadBoy opened 5 years ago

DreadBoy commented 5 years ago

Check List

Please check followings before submitting a new issue.

How to reproduce?

Create new helper and put it in themes/theme_name/scripts, for example:

hexo.extend.helper.register('reports', function () {
    console.log('reports');
    return 'reports';
});

Start hexo server and edit helper file.

Expected behavior

Hexo should recompile when helper files is changed.

Actual behavior

Hexo won't recompile and if I refresh page, helper still console.logs and returns original value.

Environment & Settings

Node.js & npm version

Node.js: 10.15.3
npm: 6.4.1

Your site _config.yml (Optional)

# Hexo Configuration
## Docs: https://hexo.io/docs/configuration.html
## Source: https://github.com/hexojs/hexo/

# Site
title: The Great Awakening
subtitle:
description:
keywords:
author: Matic Leva in ostali
language: en
timezone:

# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: https://dreadboy.github.io/the-great-awakening/
root: /the-great-awakening/
permalink: :category/:title/
permalink_defaults:

# Directory
source_dir: source
public_dir: public
tag_dir: tags
archive_dir: archives
category_dir: categories
code_dir: downloads/code
i18n_dir: :lang
skip_render:

# Writing
new_post_name: :title.md # File name of new posts
default_layout: post
titlecase: true # Transform title into titlecase
external_link: true # Open external links in new tab
filename_case: 0
render_drafts: false
post_asset_folder: true
relative_link: false
future: true
highlight:
  enable: true
  line_number: true
  auto_detect: false
  tab_replace:

# Home page setting
# path: Root path for your blogs index page. (default = '')
# per_page: Posts displayed per page. (0 = disable pagination)
# order_by: Posts order. (Order by date descending by default)
index_generator:
  path: ''
  per_page: 0

# Category & Tag
default_category: uncategorized
category_map:
tag_map:

# Date / Time format
## Hexo uses Moment.js to parse and display date
## You can customize the date format as defined in
## http://momentjs.com/docs/#/displaying/format/
date_format: dddd, MMMM Do YYYY
time_format: HH:mm:ss

# Pagination
## Set per_page to 0 to disable pagination
per_page: 10
pagination_dir: page

# Extensions
## Plugins: https://hexo.io/plugins/
## Themes: https://hexo.io/themes/
theme: dnd

# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
  type: git   
  repo: git@github.com:DreadBoy/the-great-awakening.git  #https://bitbucket.org/JohnSmith/johnsmith.bitbucket.io
  branch: gh-pages

Your theme _config.yml (Optional)

node_sass:
  includePaths:
    - './node_modules'

Hexo and Plugin version(npm ls --depth 0)

+-- @types/jquery@3.3.31
+-- @types/leaflet@1.5.1
+-- hexo@3.9.0
+-- hexo-deployer-git@2.0.0
+-- hexo-fs@2.0.0
+-- hexo-generator-archive@1.0.0
+-- hexo-generator-category@1.0.0
+-- hexo-generator-index@1.0.0
+-- hexo-generator-tag@1.0.0
+-- hexo-render-pug@2.1.4
+-- hexo-renderer-ejs@1.0.0
+-- hexo-renderer-marked@2.0.0
+-- hexo-renderer-sass@0.4.0
+-- hexo-renderer-stylus@1.1.0
+-- hexo-renderer-ts@1.2.5
+-- hexo-server@1.0.0
+-- hexo-webpack@1.0.0
+-- jimp@0.8.3
+-- jquery@3.4.1
+-- leaflet@1.5.1
+-- rimraf@3.0.0
+-- ts-loader@6.1.0
`-- typescript@3.6.3

Your package.json package.json

{
  "name": "hexo-site",
  "version": "0.0.0",
  "private": true,
  "hexo": {
    "version": "3.9.0"
  },
  "scripts": {
    "build": "rimraf public && hexo generate",
    "deploy": "hexo deploy",
    "build-deploy": "npm run build && npm run deploy && rimraf public",
    "start": "hexo server",
    "install-cli": "npm install hexo-cli -g"
  },
  "dependencies": {
    "hexo": "^3.9.0",
    "hexo-deployer-git": "^2.0.0",
    "hexo-fs": "^2.0.0",
    "hexo-generator-archive": "^1.0.0",
    "hexo-generator-category": "^1.0.0",
    "hexo-generator-index": "^1.0.0",
    "hexo-generator-tag": "^1.0.0",
    "hexo-render-pug": "^2.1.4",
    "hexo-renderer-ejs": "^1.0.0",
    "hexo-renderer-marked": "^2.0.0",
    "hexo-renderer-sass": "^0.4.0",
    "hexo-renderer-stylus": "^1.1.0",
    "hexo-renderer-ts": "^1.2.5",
    "hexo-server": "^1.0.0",
    "hexo-webpack": "^1.0.0",
    "jimp": "^0.8.3",
    "jquery": "^3.4.1",
    "leaflet": "^1.5.1",
    "rimraf": "^3.0.0",
    "ts-loader": "^6.1.0",
    "typescript": "^3.6.3"
  },
  "devDependencies": {
    "@types/jquery": "^3.3.31",
    "@types/leaflet": "^1.5.1"
  }
}
yoshinorin commented 5 years ago

@SukkaW Is this really a bug? My understanding theme/scripts load when initialize. So, even if the user adds a script after boot hexo, the script does not load.

https://hexo.io/docs/themes#scripts

PS: I think it would be nice if hexo have a hot-reload feature. But it requires a lot of work and I have no idea how to implement it.

SukkaW commented 5 years ago

@YoshinoriN Maybe I should change this to feature request..

curbengh commented 5 years ago

PS: I think it would be nice if hexo have a hot-reload feature. But it requires a lot of work and I have no idea how to implement it.

nodemon is one way to implement hot-reload in nodejs ecosystem, by restarting the server upon file change. We can implement it as an optional feature (off by default), and user can enable it if can accept few seconds of downtime.