Comments (2)
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.
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)
- extname should be transformed after executing tasks
- Exclude should not match descendant of input directory path
- Fill trailing slash if the request is likely to directory
- Cache of nested dependencies are not saved on the first build
- Accidentally end build process if the user excludes some files in their tasks
- Possibly fail a build with cache when some deps are removed
- Allow to set options to presets HOT 2
- Allow to set Browsersync options HOT 2
- Allow to set base path of dev server
- proxy option
- mtime of output files are not updated even if the dependent files are changed
- Filter input for build HOT 1
- Inaccuracy build time log
- Cache for dev server
- Error: File not found with singular glob
- Use Node v10 stream pipeline for handling error
- Inline task HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from houl.