Gathering detailed insights and metrics for postcss-import-part
Gathering detailed insights and metrics for postcss-import-part
Gathering detailed insights and metrics for postcss-import-part
Gathering detailed insights and metrics for postcss-import-part
PostCSS plugin to import external file content at any place (like partial import)
npm install postcss-import-part
Typescript
Module System
Min. Node Version
Node Version
NPM Version
68.9
Supply Chain
98.4
Quality
75.1
Maintenance
50
Vulnerability
99.6
License
TypeScript (99.68%)
CSS (0.32%)
Total Downloads
1,343
Last Day
4
Last Week
11
Last Month
27
Last Year
334
MIT License
11 Commits
1 Watchers
1 Branches
1 Contributors
Updated on Oct 14, 2018
Minified
Minified + Gzipped
Latest Version
1.1.0
Package Id
postcss-import-part@1.1.0
Unpacked Size
28.03 kB
Size
8.81 kB
File Count
24
NPM Version
6.4.1
Node Version
10.11.0
Cumulative downloads
Total Downloads
Last Day
300%
4
Compared to previous day
Last Week
266.7%
11
Compared to previous week
Last Month
80%
27
Compared to previous month
Last Year
185.5%
334
Compared to previous year
PostCSS plugin to import external file content at any place (like partial import).
To import adjacent file, path should be relative (like ./_part.css
). Can import from node_modules
(or web_modules
) as well.
Currently recursive imports are not allowed.
You can also specify Parsers for imported files by extension.
@import-part <string>;
where
<string> is path to file or module name.
1div 2{ 3 @import-part "./imports/imported.pcss"; 4}
Output:
1div 2 .imported 3 { 4 color: red; 5 } 6}
You can find more examples in tests.
npm install --save-dev postcss-import-part
It’s asynchronous plugin, so use should youse promises or async/await.
Source file path is required to resolve relative paths. If this path is not
specified, root
option is used (process.cwd()
by default).
In this example used custom resolver to process paths, started from ~/
, as
relative to __dirname
.
1const postcss = require( 'postcss' ); 2const importJson = require( 'postcss-import-json' ).default; 3 4const css = '@import-part "~/fixtures/imports/imported.pcss";'; 5const options = { 6 resolve: ( path ) => ( 7 /^~\//.test( path ) 8 ? resolve( __dirname, path.substr( 2 ) ) 9 : path 10 ), 11}; 12 13postcss( [globalVars( options )] ) 14 .process( 15 css, 16 {from: '/tmp/test.css'}, 17 ) 18 .then( 19 ( result ) => 20 { 21 console.log( result.css ); // => '.imported\n{\n\tcolor: red;\n}' 22 }, 23 );
root
Type: string
Default: process.cwd()
The root directory where to resolve path. Used to resolve relative paths when path of source file is not specified.
moduleDirectory
Type: string[]
Default: ['web_modules', 'node_modules']
Directory (or directories) in which to recursively look for modules.
paths
Type: string[]
Default: []
Paths array to use if nothing is found on the normal node_modules recursive walk.
plugins
Type: postcss.AcceptedPlugin[]
Default: []
PostCSS plugins to be applied on each imported files.
parsers
Type: {[key: string]: Parse | Syntax}
Default: {}
PostCSS parsers by file extension. Object key should be an extension as path.extname
result, and value should be a parser plugin.
1{ 2 '.sss': require( 'sugarss' ), 3}
resolve
Type: ( uri: string, basedir: string, options: PluginOptions ): string | Promise<string>
Default: undefined
Custom path resolver. Relative path can be returned to continue processing with default resolver.
Function arguments:
uri
— URI from import rule (original path).basedir
— Base directory for current import.options
— Plugin options.MIT.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 0/11 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
14 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-06-30
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More