{"name":"postcss-import","version":"17.0.0","keywords":["css","postcss","postcss-plugin","import","node modules","npm"],"author":{"name":"Maxime Thirouin"},"license":"MIT","_id":"postcss-import@17.0.0","maintainers":[{"name":"ai","email":"andrey@sitnik.es"},{"name":"ryanzim","email":"opensrc@ryanzim.com"},{"name":"romainmenke","email":"romainmenke@gmail.com"}],"homepage":"https://github.com/postcss/postcss-import#readme","bugs":{"url":"https://github.com/postcss/postcss-import/issues"},"dist":{"shasum":"b545e9c4cfd48791e7090b3ff232b7b93d075139","tarball":"http://registry-npm.ywwl.com/postcss-import/download/postcss-import-17.0.0.tgz","fileCount":15,"integrity":"sha512-qzVMJhcq39KweT7Fp0HcjE5YxL5yI854Q3CtufxDuZKO9HLQUp2rptB9+U0MIj3pT1ZEVXoqnpeC1mSkfYuz4Q==","signatures":[{"sig":"MEUCIAznNmsIAJ3lEoKNT6j0Oi0CuvTvI6+rdYftFBpyd9QuAiEA+ku2SqxuHG/9ViFYGrwGKegGFe8SjWVIQHoUmQz88mY=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEUCIQC5rf3HTHNAjFMiN2cyxqXRj11Lm7LwEAlMcn9jl7YzygIgESUQx3qJnqeD2Mkgr0IRFNOaq0R0xhr5OVjbUgzcbQE=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":30089,"size":9655,"noattachment":false,"key":"/postcss-import/-/postcss-import-17.0.0.tgz"},"engines":{"node":">=22.0.0"},"gitHead":"7b5a28c202e37f243783e409394cd3286c5fc77e","scripts":{"ci":"eslint . && ava","lint":"eslint . --fix","test":"c8 ava","pretest":"npm run lint"},"_npmUser":{"name":"ryanzim","email":"opensrc@ryanzim.com"},"repository":{"url":"git+https://github.com/postcss/postcss-import.git","type":"git"},"_npmVersion":"11.17.0","description":"PostCSS plugin to import CSS files","directories":{},"_nodeVersion":"26.5.0","dependencies":{"resolve":"^1.1.7","read-cache":"^1.0.0","postcss-value-parser":"^4.0.0"},"_hasShrinkwrap":false,"devDependencies":{"c8":"^12.0.0","ava":"^8.0.0","eslint":"^10.8.1","globals":"^17.0.0","postcss":"^8.5.19","sugarss":"^5.0.0","prettier":"~3.9.0","postcss-scss":"^4.0.0","eslint-config-problems":"^10.0.1","eslint-plugin-prettier":"^5.0.0"},"peerDependencies":{"postcss":"^8.0.0"},"_npmOperationalInternal":{"tmp":"tmp/postcss-import_17.0.0_1786734688578_0.6375420026275092","host":"s3://npm-registry-packages-npm-production"},"readme":"# postcss-import\n\n[![Version](https://img.shields.io/npm/v/postcss-import)](https://github.com/postcss/postcss-import/blob/master/CHANGELOG.md)\n[![postcss compatibility](https://img.shields.io/npm/dependency-version/postcss-import/peer/postcss)](https://postcss.org/)\n\n> [PostCSS](https://github.com/postcss/postcss) plugin to transform `@import`\nrules by inlining content.\n\nThis plugin can consume local files, node modules or web_modules.\nTo resolve path of an `@import` rule, it can look into root directory\n(by default `process.cwd()`), `web_modules`, `node_modules`\nor local modules.\n_When importing a module, it will look for `index.css` or file referenced in\n`package.json` in the `style` or `main` fields._\nYou can also provide manually multiples paths where to look at.\n\n**Notes:**\n\n- **This plugin should probably be used as the first plugin of your list.\nThis way, other plugins will work on the AST as if there were only a single file\nto process, and will probably work as you can expect**.\n- Running [postcss-url](https://github.com/postcss/postcss-url) after\npostcss-import in your plugin chain will allow you to adjust assets `url()` (or\neven inline them) after inlining imported files.\n- In order to optimize output, **this plugin will only import a file once** on\na given scope (root, media query...).\nDuplicates are detected by the resolved file path.\nIf this behavior is not what you want, look at `skipDuplicates` option\n- If you are looking for **Glob Imports**, you can use [postcss-import-ext-glob](https://github.com/dimitrinicolas/postcss-import-ext-glob) to extend postcss-import.\n- If you want to import remote sources, you can use [postcss-import-url](https://github.com/unlight/postcss-import-url) with its `dataUrls` plugin option to extend postcss-import.\n- Imports which are not modified (by `options.filter` or because they are remote\n  imports) are moved to the top of the output.\n- **This plugin attempts to follow the CSS `@import` spec**; `@import`\n  statements must precede all other statements (besides `@charset` and `@layer`).\n\n## Installation\n\n```console\n$ npm install -D postcss-import\n```\n\n## Usage\n\nUnless your stylesheet is in the same place where you run postcss\n(`process.cwd()`), you will need to use `from` option to make relative imports\nwork.\n\n```js\n// dependencies\nconst fs = require(\"fs\")\nconst postcss = require(\"postcss\")\nconst atImport = require(\"postcss-import\")\n\n// css to be processed\nconst css = fs.readFileSync(\"css/input.css\", \"utf8\")\n\n// process css\npostcss()\n  .use(atImport())\n  .process(css, {\n    // `from` option is needed here\n    from: \"css/input.css\"\n  })\n  .then((result) => {\n    const output = result.css\n\n    console.log(output)\n  })\n```\n\n`css/input.css`:\n\n```css\n/* remote urls are preserved */\n@import \"https://example.com/styles.css\";\n\n/* can consume `node_modules`, `web_modules` or local modules */\n@import \"cssrecipes-defaults\"; /* == @import \"../node_modules/cssrecipes-defaults/index.css\"; */\n@import \"normalize.css\"; /* == @import \"../node_modules/normalize.css/normalize.css\"; */\n\n@import \"foo.css\"; /* relative to css/ according to `from` option above */\n\n/* all standard notations of the \"url\" value are supported */\n@import url(foo-1.css);\n@import url(\"foo-2.css\");\n\n@import \"bar.css\" (min-width: 25em);\n\n@import 'baz.css' layer(baz-layer);\n\nbody {\n  background: black;\n}\n```\n\nwill give you:\n\n```css\n@import \"https://example.com/styles.css\";\n\n/* ... content of ../node_modules/cssrecipes-defaults/index.css */\n/* ... content of ../node_modules/normalize.css/normalize.css */\n\n/* ... content of css/foo.css */\n\n/* ... content of css/foo-1.css */\n/* ... content of css/foo-2.css */\n\n@media (min-width: 25em) {\n/* ... content of css/bar.css */\n}\n\n@layer baz-layer {\n/* ... content of css/baz.css */\n}\n\nbody {\n  background: black;\n}\n```\n\nCheckout the [tests](test) for more examples.\n\n### Options\n\n#### `filter`\nType: `Function`  \nDefault: `() => true`\n\nOnly transform imports for which the test function returns `true`. Imports for\nwhich the test function returns `false` will be left as is. The function gets\nthe path to import as an argument and should return a boolean.\n\n#### `root`\n\nType: `String`  \nDefault: `process.cwd()` or _dirname of\n[the postcss `from`](https://github.com/postcss/postcss#node-source)_\n\nDefine the root where to resolve path (eg: place where `node_modules` are).\nShould not be used that much.  \n_Note: nested `@import` will additionally benefit of the relative dirname of\nimported files._\n\n#### `path`\n\nType: `String|Array`  \nDefault: `[]`\n\nA string or an array of paths in where to look for files.\n\n#### `plugins`\n\nType: `Array`  \nDefault: `undefined`\n\nAn array of plugins to be applied on each imported files.\n\n#### `resolve`\n\nType: `Function`  \nDefault: `null`\n\nYou can provide a custom path resolver with this option. This function gets\n`(id, basedir, importOptions, astNode)` arguments and should return a path, an array of\npaths or a promise resolving to the path(s). If you do not return an absolute\npath, your path will be resolved to an absolute path using the default\nresolver.\nYou can use [resolve](https://github.com/substack/node-resolve) for this.\n\n#### `load`\n\nType: `Function`  \nDefault: null\n\nYou can overwrite the default loading way by setting this option.\nThis function gets `(filename, importOptions)` arguments and returns content or\npromised content.\n\n#### `skipDuplicates`\n\nType: `Boolean`  \nDefault: `true`\n\nBy default, repeated imports of the same file are skipped.\nSet this option to `false` to inline a file each time it is imported.\n\n#### `addModulesDirectories`\n\nType: `Array`  \nDefault: `[]`\n\nAn array of folder names to add to [Node's resolver](https://github.com/substack/node-resolve).\nValues will be appended to the default resolve directories:\n`[\"node_modules\", \"web_modules\"]`.\n\nThis option is only for adding additional directories to default resolver. If\nyou provide your own resolver via the `resolve` configuration option above, then\nthis value will be ignored.\n\n#### `warnOnEmpty`\n\nType: `Boolean`  \nDefault: `true`\n\nBy default `postcss-import` warns when an empty file is imported.  \nSet this option to `false` to disable this warning.\n\n#### Example with some options\n\n```js\nconst postcss = require(\"postcss\")\nconst atImport = require(\"postcss-import\")\n\npostcss()\n  .use(atImport({\n    path: [\"src/css\"],\n  }))\n  .process(cssString)\n  .then((result) => {\n    const { css } = result\n  })\n```\n\n## `dependency` Message Support\n\n`postcss-import` adds a message to `result.messages` for each `@import`. Messages are in the following format:\n\n```\n{\n  type: 'dependency',\n  file: absoluteFilePath,\n  parent: fileContainingTheImport\n}\n```\n\nThis is mainly for use by postcss runners that implement file watching.\n\n---\n\n## CONTRIBUTING\n\n* ⇄ Pull requests and ★ Stars are always welcome.\n* For bugs and feature requests, please create an issue.\n* Pull requests must be accompanied by passing automated tests (`$ npm test`).\n\n## [Changelog](CHANGELOG.md)\n\n## [License](LICENSE)\n","publish_time":1786734688703,"_cnpm_publish_time":1786734688703,"dist-tags":{"latest":"17.0.1"}}