📦 Universal JavaScript library bundler, powered by Rollup.
- custom configuration file
- Violent monitoring, monitoring can be turned on
npm install @yzfu/libuild
Add a configuration file libuild.config.mjs
in the project root directory, the file may not match
// libuild.config.mjs
{
libraryName: 'demo' // export package name
targets: ['esm', 'cjs', 'umd'] // build target
}
In package.json
add:
// -w Enable monitoring, you can monitor the specified directory libbuild -w ./src/xxx/, default monitoring ./src/
// -c Specify configuration file, build -c ./config/index.js, default root directory libbuild.config.mjs
{
"scripts": {
"dev": "libuild -w",
"build": "libuild"
}
}
- dist
- node
- index.js
- index.js.map
- node-cjs
- index.cjs
- index.cjs.map
- types
- index.d.ts
- node
The compiled file name, the compiled file name, defaults to the name in package.json
The scope symbol (@
) will be ignored for conversion, for example: @yzfu/-xxx
-> yzfu-xxx
Entry file, default ./src/index.{ts, js}
,
Determine whether it is ts
or js
according to whether there is typescript
dependency in package.json
of the project
After compiling dist
directory, the default root directory generates dist
Whether to enable sourcemap
build target, optional, cjs, esm, umd
export mode, see https://rollupjs.org/guide/en/#outputpreservemodules
Configure @rollup/plugin-node-resolve, see https://github.com/rollup/plugins/tree/master/packages/node-resolve
Dependency module ID parsing, see https://rollupjs.org/configuration-options/#external
example:
export default {
external: {
'vue': 'Vue',
'vue-router': 'VueRouter'
}
}
typescript
configuration, tsconfig
defaults to tsconfig.json`` in the root directory, and the default configuration depends on whether
typescriptexists in
package.json` in the project
Monitor mode, not enabled by default, monitor string path, for example:
export default {
watch: './src/'
}