
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
mini-css-themes-plugin
Advanced tools
Generates themes for webpack css modules based setup. Requires mini-css-extract-plugin as it depends on it to generate the different themes css files. Currently it supports only SASS.
npm i --save mini-css-themes-plugin
const MiniCssThemesWebpackPlugin = require('mini-css-themes-plugin');
// ...
module.exports = {
plugins: [
new MiniCssThemesWebpackPlugin({
themes: {
'theme_one': './path/to/theme_one/theme.scss',
'theme_two': './path/to/theme_two/theme.scss',
},
defaultTheme: 'theme_one'
})
]
};
The plugin will duplicate all css modules imports found in js modules for each non default theme. These duplicates will then have their own compilation and a special loader will change the default theme path import in scss files. Finally new chunk is generated for each non default theme.
With the installation example and with two entrypoints you will have the following additional chunks asset outputs:
This plugin is not providing the loading mechanism of these themes. You will have to write that yourself. Considering that you also have the webpack manifest plugin:
const defaultTheme: string = 'theme_one';
const selectedTheme: string = 'theme_two';
// Here manifest is the loaded manifest.json.
const loadThemes: (entrypoint: string) => Array<Promise<any>> = (entrypoint) =>
Object.keys(manifest)
.filter((file: string) => {
if (selectedTheme !== defaultTheme) {
// There can be multiple chunks for same theme for this entry.
return file.indexOf(`theme__${selectedTheme}~${entrypoint}`) === 0 && file.match(/\.css$/)
} else {
return file.indexOf(entrypoint) === 0 && file.match(/\.css$/)
}
})
// addCss should take care of loading the css file in the DOM.
.map((file: string) => addCss(manifest[file]));
Promise.all([
...loadThemes('entrypoint_1'),
]).then(() => {
// ... proceed to render your application ...
});
Using composes
with switchable themes is supported, but not recommended as it will
slow down unnecessarily the compilation. Prefer extracting components instead of
relying on composes
.
It is recommended to separate all classes that get composed in a separate file in order to avoid bloating the css modules with many unused classes. This means that one needs to have multiple entry points per theme. Here is an example how to do this:
In webpack config:
new MiniCssThemesWebpackPlugin({
themes: {
'theme_one': {
default: './path/to/theme_one/theme.scss',
composes: './path/to/theme_one/composes.scss'
},
'theme_two': {
default: './path/to/theme_two/theme.scss',
composes: './path/to/theme_one/composes.scss'
},
},
defaultTheme: 'theme_one'
});
Then in css modules using composes.
@import './path/to/theme_one/theme.scss';
.composed {
composes: someClass from './path/to/theme_one/composes.scss';
}
// MyComponent.scss
@import './something/not/from/the/theme.scss'
// ./something/not/from/the/theme.scss
// This import won't be switched when generating the themes and the values below
// will remain the same for all themes.
@import './path/to/theme_one/theme.scss'
$myOtherVar: $themeVar1 + $themeVar2
.css
imports from your sources or from under
node modules into the separate themes. Since these are not themable anyway it is advised
to separate this css imports in their own files (common chunks) and then load them for all
themes. This is good for caching and theme file size overall.FAQs
Webpack plugin to generate separate themes for css modules.
The npm package mini-css-themes-plugin receives a total of 32 weekly downloads. As such, mini-css-themes-plugin popularity was classified as not popular.
We found that mini-css-themes-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.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.