Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
html-webpack-jsdom-prerender-plugin
Advanced tools
Webpack plugin to prerender JS apps in a JSDOM context
A plugin to prerender and inject JavaScript apps into the static markup generated by html-webpack-plugin at build time. This was heavily inspired by html-webpack-prerender-plugin by Reuters Graphics.
Install this package and html-webpack-plugin
as dev dependencies
yarn add --dev html-webpack-plugin html-webpack-jsdom-prerender-plugin
Add the plugins to your webpack configuration
// webpack.config.js
const HtmlWebpackPlugin = require('html-webpack-plugin')
const HtmlWebpackJsdomPrerenderPlugin = require('html-webpack-jsdom-prerender-plugin')
module.exports = {
entry: './src/js/index.js',
output: {
path: './dist',
filename: '[name].js',
},
// ...
plugins: [
new HtmlWebpackPlugin({
filename: 'index.html',
template: './src/templates/index.html',
}),
new HtmlWebpackJsdomPrerenderPlugin({
'index.html': {
chunks: ['main'],
},
}),
],
}
Create an HTML template for your app
<!-- src/templates/index.html -->
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head></head>
<body>
<div id='root'></div>
</body>
</html>
Make sure your app will change the DOM when it runs. If you're using
a framework like React you can use the flag
window.__HTML_WEBPACK_JSDOM_PRERENDER_PLUGIN__
to see if your app is
running in a prerender environment rather than on the client.
// src/js/index.js
import React from 'react'
import { render } from 'react-dom'
import { renderToString } from 'react-dom/server'
import Component from './my-component'
const node = document.getElementById('root')
if (window.__HTML_WEBPACK_JSDOM_PRERENDER_PLUGIN__) {
node.innerHTML = renderToString(<Component />)
} else {
render(<Component />, node)
}
Note The plugin only currently supports two types of publicPath
: "auto" (the same behavior as if the publicPath is excluded) and a path relative to the root, for example "/assets".
FAQs
Webpack plugin to prerender JS apps in a JSDOM context
The npm package html-webpack-jsdom-prerender-plugin receives a total of 0 weekly downloads. As such, html-webpack-jsdom-prerender-plugin popularity was classified as not popular.
We found that html-webpack-jsdom-prerender-plugin demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.