Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
pcss-loader
Advanced tools
A loader for Webpack that imports pcss files and return js modules.
Install with npm i -D pcss-loader
. Then your webpack configuration must contain the following module:
...
module: {
rules: [
...
{
// You can use antoher extension
test: /\.pcss$/i,
// You can also exclude, but inclusion is
// more specific and more predictable
include: 'your_src_folder_path',
use: {
loader: 'pcss-loader',
// Not mandatory
options: {}
}
}
]
},
...
options: {
// Set to true to minify the output, important for production
minified: false,
// Default values for the env
presetEnv: {
stage: 0,
features: ['css-nesting'],
browsers: 'cover 100%'
},
// Array of additionnal plugins
// you can add any post-css plugin
customPlugins: []
}
You can read the documentation about postcss-preset-env to learn more about the options you can pass to presetEnv
.
You can add any plugins you want to post-css with the customPlugins
array. But here are the ones currently in use.
@
imports like @import 'src/UiAssets/Colors.pcss';
.$
vars.minified
option to true.If you have the two following pcss files:
/* Colors.pcss */
$mainColor: #00c;
/* Styles.pcss */
@import 'src_path/Colors.pcss';
body {
color: #000;
}
.__SCOPE {
color: #c00;
> .example {
color: $mainColor;
}
}
And you import them in a JavaScript file with import AppStyles from './AppStyles.pcss';
, you obtain this object:
{
hash: "_d9ce6323d17badc0ff20482741b70d84",
styles: `
body {
color: #000;
}
._d9ce6323d17badc0ff20482741b70d84 {
color: #c00;
}
._d9ce6323d17badc0ff20482741b70d84 > .example {
color: #00c;
}
`,
}
It should be injected in a style
tag in your DOM.
The value of
styles
will be minified if you passminified: true
in the options and will be:body{color:#000}._8fd83ea9dc8f28944de69aac4284bba3{color:#c00}._8fd83ea9dc8f28944de69aac4284bba3>.example{color:#00c}
.__SCOPE
classThe loader uses that class to scope your styles. Then you can use the hash returned by the loader as a class for the container and so the styles will be scoped only to his children.
You can also store the hash to make sure that you don't inject twice the same styles.
The styles in
body
are not nested in the__SCOPE
class. The loader put them in the global scope.
FAQs
Webpack loader for pcss files
We found that pcss-loader 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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.