Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
elm-css-modules-loader
Advanced tools
A Webpack loader that enables you to reference CSS modules in Elm source files.
Start with a CSS file that can be imported by Webpack using css-loader:
.something {
⋮
}
.anotherThing {
⋮
}
In any Elm module, reference this stylesheet and the classes you want to use in it:
module Styles exposing (..)
import CssModules exposing (CssModule(..))
styles =
CssModule "./stylesheet.css" -- relative to main Elm source directory
{ something = "" -- strings will be populated by Webpack at build time!
, anotherThing = ""
}
Then use the included class
function to use the class names in your view:
module Main exposing (..)
import CssModules exposing (class)
import Styles exposing (styles)
view : Html Msg
view =
div
[ class styles .something ]
[ text "this is a div"]
We wanted to use the same style sheets for the standard components in our application (buttons, form fields, etc.) across two different implementations of these components (React and Elm). We love the namespacing and composition features of CSS Modules; this project seeks to make them usable within Elm views.
Note: elm-css is the de facto standard for writing styles for HTML interfaces written in Elm. If you are working on an all-Elm application, you should probably use that.
To get this working, you need to set up a combination of a Webpack loader and and Elm package.
Add the elm-css-modules-loader
NPM package to your project, then configure
Webpack to chain it with elm-webpack-loader:
module.exports = {
⋮
module: {
loaders: [
{
test: /\.elm$/,
loaders: ['elm-css-modules-loader', 'elm-webpack'],
},
⋮
],
},
};
Install the CultureAmp/CssModules
package in your Elm project, then use the
features provided: the CssModule
constructor (for referencing CSS modules),
and the class
and classList
HTML attribute functions.
Currently this only works with Webpack 1.x. Webpack 2 support is at the top the our to-do list.
You cannot reference class names that are not valid Elm record keys.
FAQs
webpack loader for using CSS modules in Elm code
The npm package elm-css-modules-loader receives a total of 0 weekly downloads. As such, elm-css-modules-loader popularity was classified as not popular.
We found that elm-css-modules-loader demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 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 researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.