Security News
The Unpaid Backbone of Open Source: Solo Maintainers Face Increasing Security Demands
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
esbuild + post builds(copy files, inject html, run static server, and watch files)
bojagi is a a traditional Korean wrapping cloth for books, gifts, etc.
$ npm i bojagi -D
$ bojagi build
$ bojagi serve
$ bojagi <section> # any section in bojagi.config.js
const bojagi = require('bojagi');
bojagi.build(options).then(esbuildResult => {
...
})
all esbuild options are allowed, https://esbuild.github.io/api/#build-api.
preBuilds: an array of function to run before esbuild.build() Example
module.exports = {
build: {
entryPoints: ['src/main.js'],
entryNames: '[name]-[hash]',
outdir: 'dist',
bundle: true,
...
preBuilds: [ function clear() {rimraf('dist')} ],
...
}
}
postBuilds: an array of function to run after esbuild.build().
a post build function takes two parameters internally
module.exports = {
build: {
entryPoints: ['src/main.js'],
entryNames: '[name]-[hash]',
outdir: 'dist',
bundle: true,
...
postBuilds: [
function(options, buildResult) { // run a websocket server
const wss = new WebSocketServer({ port: 8081});
wss.on('connection', socket => wsClients.push(socket));
}
]
}
}
A full example can be found here. https://github.com/elements-x/elements-x/blob/master/bojagi.config.js
esbuild plugin that minify css and html
src/main.js
import html from './test.html';
import css from './test.css';
console.log(html + css);
Example
const bojagi = require('bojagi');
const { minifyCssPlugin, minifyHtmlPlugin } = bojagi.esbuildPlugins;
const options = {
entryPoints: ['src/main.js'],
plugins: [minifyCssPlugin, minifyHtmlPlugin]
};
bojagi.build(options).then(esbuildResult => {
...
});
copy files to a directory by replacing file contents
Example
const bojagi = require('bojagi');
const {copy} = bojagi.postBuilds
const options = {
entryPoints: ['src/main.js']
postBuilds: [
copy('src/**/!(*.js) public/* dist', {
replacements: [ {match: /index\.html/, find: /FOO/, replace: 'BAR'} ]
})
]
}
bojagi.build(options).then(esbuildResult => {
...
})
Inject esbuild compile output to index.html.
e.g.
<!-- your index.html -->
<script src="main.js"></script>
<link rel="stylesheet" href="style.css" />
</body>
</html>
Example
const bojagi = require('bojagi');
const {injectEsbuildResult} = bojagi.postBuilds;
const options = {
entryPoints: ['src/main.js']
postBuilds: [ injectEsbuildResult() ]
}
bojagi.build(options).then(esbuildResult => {
...
})
Run a static http server for a given directory. Two parameters accepted
require('memfs')
. Default require('fs')
.{match: /.*$/, serve: path.join(dir, 'index.html')}
Example
const bojagi = require('bojagi');
const {runStaticServer} = bojagi.postBuilds;
const options = {
entryPoints: ['src/main.js']
postBuilds: [
runStaticServer('src', {
fs: require('memfs'),
port: 9100,
notFound: {match: /.*$/, serve: path.join(dir, 'index.html')
}})
]
}
bojagi.build(options).then(esbuildResult => {
...
})
Watch the given directory, and rebuild and reload when a file change happens It also statts a websocket server to reload browser client when file change happens.
Parameters:
Example
const bojagi = require('bojagi');
const {watchAndReload} = bojagi.postBuilds;
const options = {
entryPoints: ['src/main.js']
postBuilds: [
watchAndReload('src', 9110)
]
}
bojagi.build(options).then(esbuildResult => {
...
})
FAQs
esbuild + post builds(copy files, inject html, run static server, and watch files)
The npm package bojagi receives a total of 1 weekly downloads. As such, bojagi popularity was classified as not popular.
We found that bojagi demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.
Security News
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.