Socket
Book a DemoInstallSign in
Socket

@node-loader/postcss

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@node-loader/postcss

A NodeJS loader for processing PostCSS

latest
Source
npmnpm
Version
2.0.0
Version published
Maintainers
1
Created
Source

@node-loader/postcss

A nodejs loader for postcss. This allows you to load CSS files into NodeJS programs by converting them into Javascript modules. The returned ES module has a default property whose value is the compiled CSS string.

Installation

npm install --save @node-loader/postcss

Node 16.12 changed the hooks used in NodeJS loaders. If using Node<16.12, use @node-loader/postcss@1. Otherwise, use @node-loader/postcss@latest.

Usage

Create a postcss.config.js file in your current working directory. Now run node with the --loader (or --experimental-loader for older NodeJS version) flag:

node --loader @node-loader/postcss file.js

Now you can import CSS files as ES modules in your NodeJS project:

import cssString from "./main.css";

console.log(
  "After PostCSS processing, the main.css file content is",
  cssString
);

Configuration

By default, node-loader postcss looks for a configuration file called postcss.config.js in the current working directory. To specify the file path to the configuration file, provide the POSTCSS_CONFIG environment variable:

POSTCSS_CONFIG=/Users/name/some/dir/.postcssrc node --loader @node-loader/postcss file.js

Composition

If you wish to combine postcss loading with other NodeJS loaders, you may do so by using node-loader-core.

Keywords

node

FAQs

Package last updated on 09 Nov 2021

Did you know?

Socket

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.

Install

Related posts