Giter VIP home page Giter VIP logo

hexo-webpack's Introduction

hexo-webpack

Yet another Hexo plugin to enable awesome Webpack package system in your Hexo site.

Build Status npm semantic-release Gitmoji

Features

  • Support for conventional webpack.config.js*

    webpack.config.js is recommended by Webpack official.

  • Contextual configuration (instance webpack config or theme webpack config)

    If the theme author cannot handle the webpack config of his/her theme, he/she cannot even find his/her javascript files to include theme into templates! ๐Ÿคฃ

  • Contextual entry path resolution

    Along with the contextual configuration, webpack entries should also be resolved from their context!

  • Hexo cache integration

    WIP ๐Ÿšง

    Speed up the build process! ๐Ÿš€

Why not? ๐Ÿค”

The most significant reason is that, you cannot provide a logical condition when configuring Webpack because both of the 2 plugins only support static configuration, that is, Hexo's YAML config files. Besides, you lose the support from awesome Webpack plugins in Hexo.

About Hexo renderers ๐ŸŽจ

Renderering a file sounds like performing transformation to a file and it should be a 1-to-1 relationship between the source file and the rendered file.

However, in Webpack, you can configure multiple targets for the same entrypoint which results in a 1-to-several relationship.

Therefore, not to be offensive to anyone but for a better experience webpacking in Hexo, I don't think renderer is a proper way to integrate Webpack with Hexo.

Core concepts ๐Ÿ’ก

๐Ÿšง To be continued...

  • Hexo generator
    • to generate routes for output files, and detect whether entry files have been changed or not
  • Event generateAfter
    • to remove entry files from routers
    • to ensure all output files are in routes

Documentation

Terminology

Frequently used terms in this document are defined here.

contextual configuration

Configuration that is aware of where the config file is, that is, in the instance or in a theme.

instance

Your hexo instance, everything about your site, including posts, pages, data assets, scripts, source files, etc.

instance config

Referred to <hexo_root>/_config.yml.

instance webpack config

Referred to <hexo_root>/webpack.config.js*.

theme

The theme for your hexo instance, placed under <hexo_root>/themes/<theme_name>/, including templates, data assets, scripts, source files, etc.

theme config

Referred to <hexo_root>/themes/<theme_name>/_config.yml.

theme webpack config

Referred to <hexo_root>/themes/<theme_name>/webpack.config.js*.

Configuration precedence

Configuration may be done at several places as shown in the table below. Rows in the table are in descending precedence; that is, the first valid config found is the effective one.

No configuration merging accross the listed places are performed in order to keep the configuration processing simple. It's recommended to decide one place and place all necessary configs in the chosen place.

For the instance

Precedence File Config Key
1 (highest) <hexo_root>/_config.yml webpack
0 (lowest) <hexo_root>/webpack.config.js*

For the theme

Precedence File Config Key
2 (highest) <hexo_root>/_config.yml theme_config.webpack
1 <hexo_root>/themes/<theme_name>/_config.yml webpack
0 (lowest) <hexo_root>/themes/<theme_name>/webpack.config.js*

Path resolution

Entry paths

Each entry path is resolved from the source/ folder of its context; that is, an entry in the theme webpack config is resolved from <hexo_root>/themes/<theme_name>/source/ while an entry in the instance webpack config is resolved from <hexo_root>/source/.

Output paths

All output path are resolved under <hexo_root>/public/.

hexo-webpack's People

Contributors

momocow avatar sshwy avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.