Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
pxtorem-webpack-plugin
Advanced tools
A webpack plugin for generating rem for stylesheet and inject auto calculate scripts.
npm install pxtorem-webpack-plugin --save-dev
This plugin should be used with html-webpack-plugin
const HtmlWebpackPlugin = require('html-webpack-plugin');
const PxtoremWebpackPlugin = require('pxtorem-webpack-plugin');
module.exports = {
// ...
plugins: [
new HtmlWebpackPlugin({
filename: 'index.html',
template: './index.html',
}),
new PxtoremWebpackPlugin({
//
templates: [
'index.html'
],
baseWidth: 750,
baseDpr: 2,
remUnit: 10,
}),
],
// ...
}
This will generate a file dist/index.html containing the following:
<!DOCTYPE html>
<html lang="en">
<head>
<script>
var designBaseWidth=750;!function(e,t){var n=e.documentElement,i="orientationchange"in window?"orientationchange":"resize",d=function(){var e=n.clientWidth;n.style.fontSize=e/t.designBaseWidth*10+"px",n.setAttribute("data-dpr",Math.floor(window.devicePixelRatio))};d(),e.addEventListener&&t.addEventListener(i,d,!1)}(document,window);
</script>
<meta charset="UTF-8">
<title>Vue webpack demo</title>
</head>
<body>
<div id="app"></div>
<script type="text/javascript" src="build.js"></script></body>
</html>
You can pass a hash of configuration options to html-webpack-plugin. Allowed values are as follows:
Name | Type | Default | Description |
---|---|---|---|
templates | {Array} | [] | The html files need to inject rem calculation scripts |
baseWidth | {Number} | 750 | The base width for UI design |
baseDpr | {Number} | 2 | base device pixel ratio |
remUnit | {Number} | 75 | rem unit value |
FAQs
Generate rem for stylesheet and inject auto calculate scripts
We found that pxtorem-webpack-plugin 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
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.