A collection of methods for build workflows relying mostly on async/await
- Node 7.8+
- NPM 3.0+
- Run
npm i --save @lump/itin your package directory. - Create the build script file at
scripts/build.js. - Add the script execution
node scripts/build.jsin thepackage.json. - Run the build with
npm run build.
No matter where your build is, the method path params expects a relative path from the project root folder.
Example, if your build script is at build/build.js and the files you want to
match inside src/files, the glob to them would be src/files/*.
The task method allows to show a spinner and a text during execution. Keeping all
code wrapped into it allows for a nicer user experience and organization.
await task({
text: 'Spinner text 1',
exec: () => copy({...})
})
// more complex tasks
await task({
text: 'Spinner text 2',
exec: async () => {
await remove(...)
await copy({...})
...
}
})With Promise.all is possible to execute a group of async tasks in parallel
while the next chunk of code awaits for the completition of all the group tasks.
await Promise.all([
copy({...}),
copy({...}),
...
])
// or inside of a task method
await task({
text: 'Build',
exec: () => Promise.all([
copy({...}),
copy({...}),
...
])
})Run the main build process.
Only one argument expected, the function to be executed.
Group and run methods with a spinner indicator.
Arguments
- text, text for the spinner
- exec, the function to be executed
Apply a banner to all matched files.
Arguments
- src, glob pattern
- banner, the banner template string
Copy matched files.
Arguments
- src, glob pattern
- dest, relative path
- options, as described at https://github.com/sindresorhus/cpy
Copy a folder recursively
Arguments
- src, glob pattern
- dest, relative path
- filter, glob pattern to exclude files
Download a file from an external resource.
Arguments
- url
- dest, relative path
Execute console commands a child_process
Arguments
- command
- options, command options
Compile a less file.
Arguments
- src, relative path
- dest, relative path
- options, less options
Minify a CSS/JS file with options source map.
Arguments
- src, relative path
- sourceMap, defaults to false
Read file content.
Argument, src to file
Write content to a file.
Arguments
- dest, relative path
- content, string
Archive and ZIP matched files.
Arguments
- src, glob pattern
- dest, zip path
Delete matched files.
Argument, blog pattern
A wrapper around rollup.
Arguments
- config, Rollup config
- options, specific lump options
- env, optional 'development' or 'production'
A wrapper around Webpack.
Arguments
- config, webpack config
This project is organized as a monorepo using Yarn Workspaces relying on Yarn 0.27.5+.
This project is open source and released under the MIT License.
Copyright (c) 2017-present, Miljan Aleksic