Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on Apr 28, 2024 via pnpm

postcss-import 15.1.0

PostCSS plugin to import CSS files
Package summary
Share
0
issues
3
licenses
12
MIT
1
ISC
1
BSD-3-Clause
Package created
10 Aug 2014
Version published
7 Dec 2022
Maintainers
2
Total deps
14
Direct deps
4
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
12 Packages, Including:
function-bind@1.1.2
hasown@2.0.2
is-core-module@2.13.1
nanoid@3.3.7
path-parse@1.0.7
pify@2.3.0
postcss-import@15.1.0
postcss-value-parser@4.2.0
postcss@8.4.38
read-cache@1.0.0
resolve@1.22.8
supports-preserve-symlinks-flag@1.0.0

ISC License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
picocolors@1.0.0

BSD 3-Clause "New" or "Revised" License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
place-warranty
Cannot
use-trademark
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
source-map-js@1.2.0
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

4
All Dependencies CSV
β“˜ This is a list of postcss-import 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities
postcss-value-parser4.2.07.81 kBMIT
prod
postcss8.4.38193.21 kBMIT
prod peer
read-cache1.0.01.88 kBMIT
prod
resolve1.22.826.69 kBMIT
prod

Visualizations

Frequently Asked Questions

What does postcss-import do?

Postcss-import is a plugin for PostCSS that transforms @import rules by inlining content. It has the functionality to consume local files, node modules, or web modules, and offers a scope of resolution for @import rules, including the root directory, web_modules, node_modules, or local modules. When importing a module, it will look for index.css or a file referenced in the style or main fields in package.json. Additionally, this plugin optimizes output by importing a file only once within a given scope, avoiding duplicates of the same file. It should be noted that the plugin needs to be used as the first plugin, so it precedes other plugins' actions to keep the Abstract Syntax Tree (AST) as a single file.

How do you use postcss-import?

Here is a guide for using postcss-import in JavaScript:

Step 1: Install the postcss-import using npm:

$ npm install -D postcss-import

Step 2: Import the required dependencies:

// dependencies
const fs = require("fs")
const postcss = require("postcss")
const atImport = require("postcss-import")

Step 3: Read the CSS to process:

// css to be processed
const css = fs.readFileSync("css/input.css", "utf8")

Step 4: Process the CSS:

// process css
postcss()
  .use(atImport())
  .process(css, {
    // `from` option is needed here
    from: "css/input.css"
  })
  .then((result) => {
    const output = result.css

    console.log(output)
  })

In the css/input.css file, you can specify which CSS files you want to import:

/* can consume `node_modules`, `web_modules` or local modules */
@import "cssrecipes-defaults"; /* == @import "../node_modules/cssrecipes-defaults/index.css"; */
@import "normalize.css"; /* == @import "../node_modules/normalize.css/normalize.css"; */

@import "foo.css"; /* relative to css/ according to `from` option above */

@import "bar.css" (min-width: 25em);

@import 'baz.css' layer(baz-layer);

body {
  background: black;
}

Where are the postcss-import docs?

The postcss-import documentation and usage examples are available on its GitHub page at https://github.com/postcss/postcss-import. The readme file there should provide you with a comprehensive guide on how to install, use, and understand the various options and configurations of postcss-import.