
Security News
Socket Releases Free Certified Patches for Critical vm2 Sandbox Escape
A critical vm2 sandbox escape can allow untrusted JavaScript to break isolation and execute commands on the host Node.js process.
@localnerve/web-component-build
Advanced tools
Assembles a web component from css, html, and js parts, assists user build flexibility
Assembles a web component from its parts, allows developers to author the component's parts in separate files.
The parts are processed and written to an output directory, then exposed to a calling build process.
The following is a table of some of the possible input, processing, and output combos. See options for detailed explanations.
| input | processing | output |
|---|---|---|
| javascript | minify javascript | javascript |
| css | minify css | css |
| html | minify html | html |
| css, html | minify css, prepend style tag to html, minify html | css, html |
| css, html, cssHref | minfy css, prepend style tag to html, prepend link tag to html, minify html | css, html |
| cssHref, html | prepend link tag to html, minify html | html |
| javascript, css | minify css, merge style tag into javascript, minify javascript | css, javascript |
| javascript, css, html | minify css, prepend style tag to html, minify html, merge into javascript, minify javascript | css, html, javascript |
| javascript, css, html, cssHref | minify css, prepend style tag to html, prepend link tag to html, minify html, merge into javascript, minify javascript | css, html, javascript |
| javascript, html | minify html, merge into javascript, minify javascript | html, javascript |
| javascript, html, cssHref | prepend link tag to html, minify html, merge into javascript, minify javascript | html, javascript |
| javascript, cssHref | add link tag to javascript, minify javascript | javascript |
By default, html minification minifies any css found therein.
// Sample usage, all options specified
import {build} from '@localnerve/web-component-build';
const outputDir = 'some/path/output';
const result = await build(outputDir, {
cssPath: '/some/path/file.css',
cssLinkHref: '//some/path/file.css',
jsPath: '/some/path/file.js',
htmlPath: '/some/path/file.html',
jsReplacement: '__REPLACEMENT_IN_JS__',
terserOptions: { /* terser options */ },
htmlminOptions: { /* html-minifier options */ },
cleancssOptions: { /* clean-css options */ },
minifySkip: false
});
// html, js, and css written to `outputDir`
// Retrieve processed content
const [js, css, html] = await Promise.all([
result.getJs(), result.getCss(), result.getHtml()
]);
// Retrieve output paths
const [jsPath, cssPath, htmlPath] = [result.jsPath, result.cssPath, result.htmlPath];
This library exports a single function that takes an output directory and processing options, returns a result object.
build (outputDir, options): Result
Full path to the output directory where css, html, and javascript output are written.
* Not really. One or more of cssPath, jsPath, and/or htmlPath must be supplied. They have no default, so if no options are supplied, this library throws an exception.
cssPath {String} - Full path to the input css file
If supplied:
cleancssOptionsstyle tagjsReplacement and jsPath are supplied and no htmlPath suppliedhtmlPath is suppliedcssLinkHref {String} - link href to a stylesheet resource to be referenced by the web component
If supplied:
link taglink will be prepended to the html file if htmlPath suppliedlink will be inserted into the javascript file if no htmlPath supplied and jsReplacement and jsPath suppliedhtmlPath {String} - Full path to the input html file
If supplied:
style taglink tagjsReplacement and jsPath is suppliedjsPath {String} - Full path to the input javascript file
jsReplacement {String|RegExp} - The replacement pattern for the css or html in the javascript file. See pattern for full documentation
If supplied:
jsPath must also be suppliedoutputDirterserOptions {Object} - The javascript minifier options object
Defaults:
{
ecma: 2022
}
htmlminOptions {Object} - The html minifier options object
Defaults:
{
minifyJS: true,
minifyCSS: true,
collapseWhitespace: true,
removeAttributeQuotes: true,
removeComments: true
}
cleancssOptions {Object} - The css minifier options object
Defaults (same as clean-css defaults)
minifySkip {Boolean} - True to skip all minifications, defaults to false
The output of the build process. Allows access to the output paths and full output content. Format:
cssPath {String}, The full path to the output css
htmlPath {String}, The full path to the output html
jsPath {String}, The full path to the output javascript
getCss {asyncFunction}, gets the output css
getHtml {asyncFunction}, gets the output html
getJs {asyncFunction}, gets the output javascript
FAQs
A library to help build web components
The npm package @localnerve/web-component-build receives a total of 32 weekly downloads. As such, @localnerve/web-component-build popularity was classified as not popular.
We found that @localnerve/web-component-build demonstrated a healthy version release cadence and project activity because the last version was released less than 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
A critical vm2 sandbox escape can allow untrusted JavaScript to break isolation and execute commands on the host Node.js process.

Research
Five malicious NuGet packages impersonate Chinese .NET libraries to deploy a stealer targeting browser credentials, crypto wallets, SSH keys, and local files.

Security News
pnpm 11 turns on a 1-day Minimum Release Age and blocks exotic subdeps by default, adding safeguards against fast-moving supply chain attacks.