Giter VIP home page Giter VIP logo

Comments (2)

ktsn avatar ktsn commented on May 27, 2024

Spending in various projects using Houl, I noticed we need the following features to extend presets better:

  • Fully overwrite a rule (this is already available in the current version)
  • Modify a part of a rule
  • Remove a rule
  • Modify a task chain (add / remove / replace gulp plugins)

The above are almost the responsibility of the preset side by handling their options for now but to adapt various use cases, the options can be very messy. So it would be better to allow these features in Houl so that the preset auther can keep simple their preset and the end-user can modify their config more flexible with arbitrary presets.

Merge configs with preset instead of replacing

Currently, we can fully overwrite a preset rule by just specifying corresponding rules field:

module.exports = {
  preset: 'foo-preset', // assume `foo-preset` has a task for `.js` files
  taskFile: './task.js',
  rules: {
    // This overwrite a task for `.js` files in the preset.
    js: {
      task: 'scripts'
    }
  }
}

This config replaces the preset .js files rule with the specified scripts task. But in the real world, there are cases we want to modify a part of the preset rule instead of replace it. e.g. adding exclude option with leaving the preset task.

To handle the case, I would prefer merging rules with preset ones instead of replacing.

Allow to mutate raw config object of preset

Similar with modification of rules, there are cases we want to remove rules in a preset. To do this, we need to allow low-level modification for preset config object. Here if we specify a function as a preset.modify field, it will receive a raw config object of preset and the user can mutate it.

module.exports = {
  preset: {
    name: 'foo-preset',
    modifyConfig: config => {
      // remove js config
      delete config.rules.js
    }
  }
}

Customize preset tasks

Customizing tasks is difficult to design its API since all tasks are combined into one stream object and the users cannot modify it.

One idea is to change that a task function returns an array of stream objects.

exports.scripts = () => [
  babel(),
  uglify()
]

But it still a bit hard to customize because the user may not able to find which plugin the array has programattically.

from houl.

ktsn avatar ktsn commented on May 27, 2024

I guess allowing array format tasks is not effective because the plugin author needs to make tasks in such form. If they does not use the format, the users cannot customize tasks in any cases.

Now merging rules and modifying preset objects are implemented. closing.

from houl.

Related Issues (18)

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.