chenzhutian / hexo-all-minifier

A plugin for Hexo that optimizes HTML, CSS, JS and imagages, and it can optionally deploys your blog.
MIT License
277 stars 30 forks source link

Run only when generating #65

Closed reyemtm closed 5 years ago

reyemtm commented 6 years ago

Here is a working line of code to add to index.js to run the minifier only when generating the site, not when serving.

if (process.argv.indexOf('server') > -1 || process.argv.indexOf('s') > -1 || process.argv.indexOf('serve') > -1) 
{
  return;
}
chenzhutian commented 5 years ago

Ok

PR is welcome. Also you can set the ENV to development to enable minifier.

const isEnabled = process.env.NODE_ENV !== 'development'
  && (hexo.config.hasOwnProperty('all_minifier') === false || hexo.config.all_minifier === true);