pax_global_header00006660000000000000000000000064143422145300014510gustar00rootroot0000000000000052 comment=2c0c3e9c7943db77b5847f9663b435e170812236 postcss-import-15.0.1/000077500000000000000000000000001434221453000146025ustar00rootroot00000000000000postcss-import-15.0.1/.editorconfig000066400000000000000000000003561434221453000172630ustar00rootroot00000000000000# editorconfig.org root = true [*] end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true indent_style = space indent_size = 2 [*.md] trim_trailing_whitespace = false [Makefile] indent_style = tab postcss-import-15.0.1/.gitattributes000066400000000000000000000000161434221453000174720ustar00rootroot00000000000000* text eol=lf postcss-import-15.0.1/.github/000077500000000000000000000000001434221453000161425ustar00rootroot00000000000000postcss-import-15.0.1/.github/workflows/000077500000000000000000000000001434221453000201775ustar00rootroot00000000000000postcss-import-15.0.1/.github/workflows/ci.yaml000066400000000000000000000006321434221453000214570ustar00rootroot00000000000000name: Node.js CI on: push: branches: master pull_request: jobs: test: runs-on: ubuntu-latest strategy: matrix: node-version: [14.x, 16.x, 18.x] steps: - uses: actions/checkout@v3 - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} - run: npm install - run: npm test postcss-import-15.0.1/.gitignore000066400000000000000000000016751434221453000166030ustar00rootroot00000000000000# Test output test/fixtures/*.actual.css # Logs logs *.log npm-debug.log* yarn-debug.log* yarn-error.log* # Runtime data pids *.pid *.seed *.pid.lock # Directory for instrumented libs generated by jscoverage/JSCover lib-cov # Coverage directory used by tools like istanbul coverage # nyc test coverage .nyc_output # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) .grunt # Bower dependency directory (https://bower.io/) bower_components # node-waf configuration .lock-wscript # Compiled binary addons (https://nodejs.org/api/addons.html) build/Release # Dependency directories /node_modules/ jspm_packages/ # Typescript v1 declaration files typings/ # Optional npm cache directory .npm # Optional eslint cache .eslintcache # Optional REPL history .node_repl_history # Output of 'npm pack' *.tgz # Yarn Integrity file .yarn-integrity # dotenv environment variables file .env # next.js build output .next postcss-import-15.0.1/.npmrc000066400000000000000000000000231434221453000157150ustar00rootroot00000000000000package-lock=false postcss-import-15.0.1/CHANGELOG.md000077500000000000000000000330451434221453000164230ustar00rootroot00000000000000# 15.0.1 / 2022-12-01 - Preserve layer in ignored `@import`s ([#510](https://github.com/postcss/postcss-import/issues/510), [#511](https://github.com/postcss/postcss-import/pull/511)) - Join media queries in the correct order ([#512](https://github.com/postcss/postcss-import/issues/512), [#513](https://github.com/postcss/postcss-import/pull/513)) # 15.0.0 / 2022-08-30 - **BREAKING:** Require Node.js v14+ ([#497](https://github.com/postcss/postcss-import/pull/497)) - **BREAKING:** Require `nameLayer` option for handling anonymous layers ([#496](https://github.com/postcss/postcss-import/pull/496)) - Fix handling of `@media` queries inside layered imports ([#495](https://github.com/postcss/postcss-import/issues/495), [#496](https://github.com/postcss/postcss-import/pull/496)) # 14.1.0 / 2022-03-22 - Add `@layer` support ([#483](https://github.com/postcss/postcss-import/pull/483)) # 14.0.2 / 2021-05-10 - Remove remaining direct import of `postcss` package ([#455](https://github.com/postcss/postcss-import/issues/455), [#456](https://github.com/postcss/postcss-import/pull/456)) # 14.0.1 / 2021-03-31 - Fix bug with `@charset` statements in media imports ([#448](https://github.com/postcss/postcss-import/issues/448), [#453](https://github.com/postcss/postcss-import/pull/453)) # 14.0.0 / 2020-12-14 This release should not have breaking changes for the vast majority of users; only those with `@charset` statements in their CSS _may_ be affected. - **BREAKING:** Error if multiple incompatible `@charset` statements ([#447](https://github.com/postcss/postcss-import/pull/447)) - **BREAKING:** Warn if `@charset` statements are not at the top of files ([#447](https://github.com/postcss/postcss-import/pull/447)) - Fix handing of `@charset` ([#436](https://github.com/postcss/postcss-import/issues/436), [#447](https://github.com/postcss/postcss-import/pull/447)) # 13.0.0 / 2020-10-20 - **BREAKING:** Require Node 10+ ([#429](https://github.com/postcss/postcss-import/pull/429)) - **BREAKING:** Upgrade to postcss v8 and require it as a `peerDependency` ([#427](https://github.com/postcss/postcss-import/issues/427), [#432](https://github.com/postcss/postcss-import/pull/432)) - Update dependencies # 12.0.1 / 2018-10-22 - Add `plugin` property to dependency messages ([#379](https://github.com/postcss/postcss-import/issues/379), [#380](https://github.com/postcss/postcss-import/pull/380)) # 12.0.0 - 2018-08-04 - Removed: Support for Node.js v4 - Changed: Uses PostCSS v7 (https://github.com/postcss/postcss/releases/tag/7.0.0) # 11.1.0 - 2018-02-10 - Added: `filter` option # 11.0.0 - 2017-09-16 - Changed: A syntax error in an imported file now throws an error instead of just warning ([#264](https://github.com/postcss/postcss-import/issues/264)) - Changed: Symlink handling to be consistent with Node.js `require` ([#300](https://github.com/postcss/postcss-import/pull/300)) # 10.0.0 - 2017-05-12 - Removed: Support for Node.js versions less than 4.5.x ([#283](https://github.com/postcss/postcss-import/pull/283)) - Changed: Upgraded to Postcss v6 ([#283](https://github.com/postcss/postcss-import/pull/283)) - Removed: jspm support ([#283](https://github.com/postcss/postcss-import/pull/283)) - Removed: deprecated `addDependencyTo` option - Removed: `onImport` option - Changed: Doesn't depend on promise-each ([#281](https://github.com/postcss/postcss-import/pull/281)) # 9.1.0 - 2017-01-10 - Added: `addModulesDirectories` option ([#256](https://github.com/postcss/postcss-import/pull/256)) # 9.0.0 - 2016-12-02 - Removed: `transform` option ([#250](https://github.com/postcss/postcss-import/pull/250)) - Removed: `pkg-resolve` is no longer a dependency; this should fix some issues with webpack. jspm users must manually install `pkg-resolve` if they want to load jspm modules (see https://github.com/postcss/postcss-import#jspm-usage for more info) ([#243](https://github.com/postcss/postcss-import/pull/243)) - Changed: If a file is not found, it will now throw an error instead of just raising a warning ([#247](https://github.com/postcss/postcss-import/pull/247)) - Changed: If a custom resolver does not return an absolute path, the default resolver will be applied to the returned path. ([#249](https://github.com/postcss/postcss-import/pull/249)) - Changed: postcss-import will try to guess the correct parser for imported files, based on the file extension. ([#245](https://github.com/postcss/postcss-import/pull/245)) - Changed: Deprecated `addDependencyTo` option, it is not needed if using postcss-loader >= v1.0.0 ([#251](https://github.com/postcss/postcss-import/pull/251)) # 8.2.0 - 2016-11-09 - Fixed: Warn about all `@import`s after other CSS declarations ([#240](https://github.com/postcss/postcss-import/pull/240)) - Added: `dependency` message ([#241](https://github.com/postcss/postcss-import/pull/241)) # 8.1.3 - 2016-11-03 - Fixed: Nested import ordering ([#236](https://github.com/postcss/postcss-import/pull/236) - @RyanZim) # 8.1.2 - 2016-05-07 - Fixed: prevent JSPM to throw unrecoverable error ([#205](https://github.com/postcss/postcss-import/pull/205)) # 8.1.1 - 2016-05-04 - Fixed: JSPM support ([#194](https://github.com/postcss/postcss-import/pull/194)) # 8.1.0 - 2016-04-04 - Added: JSPM browser field ([#186](https://github.com/postcss/postcss-import/pull/186)) # 8.0.2 - 2015-01-27 - Fixed: Comments between imports statements are ignored ([#164](https://github.com/postcss/postcss-import/pull/164)) # 8.0.1 - 2015-01-27 - Fixed: missing "lib" folder ([#161](https://github.com/postcss/postcss-import/issues/161)) # 8.0.0 - 2015-01-27 **All imports statements must be at the top of your file now, per CSS specification.** You should use [postcss-reporter](https://github.com/postcss/postcss-reporter) to see the warnings raised. - Removed: async mode/option (now async by default) ([#107](https://github.com/postcss/postcss-import/pull/107)) - Removed: "bower_components" not supported by default anymore, use "path" option to add it back - Removed: `encoding` option. Encoding can be specified in custom `load` option ```js postcssImport({ load: function(filename) { return fs.readFileSync(filename, "utf-8") } }) ``` ([#144](https://github.com/postcss/postcss-import/pull/144)) - Removed: glob support ([#146](https://github.com/postcss/postcss-import/pull/146)) Globs can be implemented with custom `resolve` option ```js postcssImport({ resolve: function(id, base) { return glob.sync(path.join(base, id)) } }) ``` ([#116](https://github.com/postcss/postcss-import/pull/116)) - Changed: custom resolve has more responsibility for paths resolving. See [resolve option](https://github.com/postcss/postcss-import#resolve) for more information about this change ([#116](https://github.com/postcss/postcss-import/pull/116)) - Changed: support promise in `transform` option and `undefined` result will be skipped ([#147](https://github.com/postcss/postcss-import/pull/147)) - Changed: `options.plugins` are applied to unprocessed ast before imports detecting ([157](https://github.com/postcss/postcss-import/pull/157)) - Added: custom resolve function can return array of paths ([#120](https://github.com/postcss/postcss-import/pull/120)) - Added: custom syntax in imported files support ([#130](https://github.com/postcss/postcss-import/pull/130)) - Added: support custom `load` option ([#144](https://github.com/postcss/postcss-import/pull/144)) - Added: detect css extension in package.json `main` field ([153](https://github.com/postcss/postcss-import/pull/153)) **Note:** _If you miss options/default behavior (glob etc), a new plugin will handle all those things. Please follow issue [#145](https://github.com/postcss/postcss-import/issues/145) _ # 7.1.3 - 2015-11-05 - Fixed: ensure node 0.12 compatibility, round 2 ([#93](https://github.com/postcss/postcss-import/pull/93)) # 7.1.2 - 2015-11-05 - Fixed: performance issue because of cloned options ([#90](https://github.com/postcss/postcss-import/pull/90)) # 7.1.1 - 2015-11-05 - Added: ensure node 0.12 compatibility # 7.0.0 - 2015-08-25 - Removed: compatibility with postcss v4.x ([#75](https://github.com/postcss/postcss-import/pull/75)) - Added: compatibility with postcss v5.x ([#76](https://github.com/postcss/postcss-import/pull/76)) - Added: lighter package by upgrading some dependencies ([#73](https://github.com/postcss/postcss-import/issues/73)) # 6.2.0 - 2015-07-21 - Added: `skipDuplicates` option now allows you to **not** skip duplicated files ([#67](https://github.com/postcss/postcss-import/issues/67)) # 6.1.1 - 2015-07-07 - Fixed: Prevent mutability issue, round 2 ([#44](https://github.com/postcss/postcss-import/issues/44)) - Added: `plugins` option, to run some postcss plugin on imported files ([#55](https://github.com/postcss/postcss-import/issues/55)) - Added: `bower_components` is now part of the default paths ([#66](https://github.com/postcss/postcss-import/issues/66)) - Added: `async` option allow to use enable PostCSS async API usage. Note that it's not enabling async fs read yet. It has been added to fix breaking change introduced by 6.1.0. # 6.1.0 - 2015-07-07 **YANKED** _This release was not respecting semver and introduced a major breaking change. It has been unpublished for now._ # 6.0.0 - 2015-06-17 - Changed: warnings messages are now using postcss message api (4.1.x) - Added: warning when a import statement has not been closed correctly ([#42](https://github.com/postcss/postcss-import/issues/42)) # 5.2.2 - 2015-04-19 - Fixed: globbed imports work for module directories ([#37](https://github.com/postcss/postcss-import/pull/37)) # 5.2.1 - 2015-04-17 - Fixed: glob import now works with single quote `@import` ([#36](https://github.com/postcss/postcss-import/pull/36)) # 5.2.0 - 2015-04-15 - Added: [glob](https://www.npmjs.com/package/glob) pattern are now supported if `glob` option is set to true ([#34](https://github.com/postcss/postcss-import/pull/34)) - Added: plugin can now be added to PostCSS without calling it as a function ([#27](https://github.com/postcss/postcss-import/pull/27)) # 5.1.1 - 2015-04-10 - Fixed: regression of 5.1.0: files which only contain same @import rules were skip ([#31](https://github.com/postcss/postcss-import/issues/31)) # 5.1.0 - 2015-03-27 - Added: files with the same content will only be imported once. Previously, only the full path was used to determine if a file has already been imported in a given scope. Now, we also test create a hash with the content of the file to check if a file with the same content has not already been imported. This might be usefull if some modules you import are importing the same library from different places (eg: normalize might be as dep for several modules located in different places in `node_modules`) ([#29](https://github.com/postcss/postcss-import/pull/28)) # 5.0.3 - 2015-02-16 - Fixed: regression of 5.0.2: AST parent references were not updated ([#25](https://github.com/postcss/postcss-import/issues/25)) # 5.0.2 - 2015-02-14 - Fixed: indentation and code style are now preserved ([#20](https://github.com/postcss/postcss-import/issues/20)) # 5.0.1 - 2015-02-13 - Fixed: breaking bug with remote stylesheets ([#21](https://github.com/postcss/postcss-import/issues/21) & [#22](https://github.com/postcss/postcss-import/issues/22)) # 5.0.0 - 2015-01-26 - Added: compatibility with postcss v4.x - Removed: compatibility with postcss v3.x - Fixed: relative imports (./ and ../) should work using `path` option only (no need for `from`) ([#14](https://github.com/postcss/postcss-import/issues/14)) # 4.1.1 - 2015-01-05 - Fixed: irregular whitespace that throw syntax error in some environnements # 4.1.0 - 2014-12-12 - Added: `web_modules` is now in module directories that are used to resolve `@import` ([#13](https://github.com/postcss/postcss-import/issues/13)). # 4.0.0 - 2014-12-11 - Added: windows compatibility (by building on AppVeyor) - Added: `root` option # 3.2.0 - 2014-11-24 - Added: `onImport` callback offers a way to get list of imported files ([ref](https://github.com/postcss/postcss-import/issues/9)) # 3.1.0 - 2014-11-24 - Added: ability to consume local modules (fix [#12](https://github.com/postcss/postcss-import/issues/12)) # 3.0.0 - 2014-11-21 - Added: ability to consume node modules ([ref](https://github.com/postcss/postcss-import/issues/7)). This means you don't have to add `node_modules` in the path anymore (or using `@import "../node_modules/..."`). Also, `index.css` can be ommited. This means something like this ```css @import "../node_modules/my-css-on-npm/index.css"; ``` can be written like this ```css @import "my-css-on-npm"; ``` Dependencies of dependencies should be resolved as well. _Note that npm resolution is done after the default local behavior._ - Changed: When importing a file multiple times in the same scope (same level of media queries), file will only be imported the first time. This is done to avoid having multiples outputs of a npm dep used multiples times in different modules. # 2.0.0 - 2014-11-12 - Added: compatibility with postcss v3.x - Removed: compatibility with postcss v2.x # 1.0.3 - 2014-10-29 - Fixed: relative import path stack # 1.0.2 - 2014-09-16 - Added: Move ignored import at top & adjust related media queries, to make them work (fix [#2](https://github.com/postcss/postcss-import/issues/2)) - Added: Ignore scheme-relative absolute URLs - Removed: `parse-import` module dependency # 1.0.1 - 2014-08-26 - Fixed: GNU message format - Added: Support empty files ([cssnext/#24](https://github.com/putaindecode/cssnext/issues/24)) # 1.0.0 - 2014-08-10 ✨ First release based on [rework-import](https://github.com/reworkcss/rework-import) v1.2.0 (mainly for fixtures) postcss-import-15.0.1/LICENSE000077500000000000000000000021361434221453000156140ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) 2014 Maxime Thirouin, Jason Campbell & Kevin Mårtensson Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. postcss-import-15.0.1/README.md000066400000000000000000000154521434221453000160700ustar00rootroot00000000000000# postcss-import [![Build](https://img.shields.io/travis/postcss/postcss-import/master)](https://travis-ci.org/postcss/postcss-import) [![Version](https://img.shields.io/npm/v/postcss-import)](https://github.com/postcss/postcss-import/blob/master/CHANGELOG.md) [![postcss compatibility](https://img.shields.io/npm/dependency-version/postcss-import/peer/postcss)](https://postcss.org/) > [PostCSS](https://github.com/postcss/postcss) plugin to transform `@import` rules by inlining content. This plugin can consume local files, node modules or web_modules. To resolve path of an `@import` rule, it can look into root directory (by default `process.cwd()`), `web_modules`, `node_modules` or local modules. _When importing a module, it will look for `index.css` or file referenced in `package.json` in the `style` or `main` fields._ You can also provide manually multiples paths where to look at. **Notes:** - **This plugin should probably be used as the first plugin of your list. This way, other plugins will work on the AST as if there were only a single file to process, and will probably work as you can expect**. - This plugin works great with [postcss-url](https://github.com/postcss/postcss-url) plugin, which will allow you to adjust assets `url()` (or even inline them) after inlining imported files. - In order to optimize output, **this plugin will only import a file once** on a given scope (root, media query...). Tests are made from the path & the content of imported files (using a hash table). If this behavior is not what you want, look at `skipDuplicates` option - 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. - Imports which are not modified (by `options.filter` or because they are remote imports) are moved to the top of the output. - **This plugin attempts to follow the CSS `@import` spec**; `@import` statements must precede all other statements (besides `@charset`). ## Installation ```console $ npm install -D postcss-import ``` ## Usage Unless your stylesheet is in the same place where you run postcss (`process.cwd()`), you will need to use `from` option to make relative imports work. ```js // dependencies const fs = require("fs") const postcss = require("postcss") const atImport = require("postcss-import") // css to be processed const css = fs.readFileSync("css/input.css", "utf8") // 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) }) ``` `css/input.css`: ```css /* 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; } ``` will give you: ```css /* ... content of ../node_modules/cssrecipes-defaults/index.css */ /* ... content of ../node_modules/normalize.css/normalize.css */ /* ... content of css/foo.css */ @media (min-width: 25em) { /* ... content of css/bar.css */ } @layer baz-layer { /* ... content of css/baz.css */ } body { background: black; } ``` Checkout the [tests](test) for more examples. ### Options ### `filter` Type: `Function` Default: `() => true` Only transform imports for which the test function returns `true`. Imports for which the test function returns `false` will be left as is. The function gets the path to import as an argument and should return a boolean. #### `root` Type: `String` Default: `process.cwd()` or _dirname of [the postcss `from`](https://github.com/postcss/postcss#node-source)_ Define the root where to resolve path (eg: place where `node_modules` are). Should not be used that much. _Note: nested `@import` will additionally benefit of the relative dirname of imported files._ #### `path` Type: `String|Array` Default: `[]` A string or an array of paths in where to look for files. #### `plugins` Type: `Array` Default: `undefined` An array of plugins to be applied on each imported files. #### `resolve` Type: `Function` Default: `null` You can provide a custom path resolver with this option. This function gets `(id, basedir, importOptions)` arguments and should return a path, an array of paths or a promise resolving to the path(s). If you do not return an absolute path, your path will be resolved to an absolute path using the default resolver. You can use [resolve](https://github.com/substack/node-resolve) for this. #### `load` Type: `Function` Default: null You can overwrite the default loading way by setting this option. This function gets `(filename, importOptions)` arguments and returns content or promised content. #### `skipDuplicates` Type: `Boolean` Default: `true` By default, similar files (based on the same content) are being skipped. It's to optimize output and skip similar files like `normalize.css` for example. If this behavior is not what you want, just set this option to `false` to disable it. #### `addModulesDirectories` Type: `Array` Default: `[]` An array of folder names to add to [Node's resolver](https://github.com/substack/node-resolve). Values will be appended to the default resolve directories: `["node_modules", "web_modules"]`. This option is only for adding additional directories to default resolver. If you provide your own resolver via the `resolve` configuration option above, then this value will be ignored. #### `nameLayer` Type: `Function` Default: `null` You can provide a custom naming function for anonymous layers (`@import 'baz.css' layer;`). This function gets `(index, rootFilename)` arguments and should return a unique string. This option only influences imports without a layer name. Without this option the plugin will warn on anonymous layers. #### Example with some options ```js const postcss = require("postcss") const atImport = require("postcss-import") postcss() .use(atImport({ path: ["src/css"], })) .process(cssString) .then((result) => { const { css } = result }) ``` ## `dependency` Message Support `postcss-import` adds a message to `result.messages` for each `@import`. Messages are in the following format: ``` { type: 'dependency', file: absoluteFilePath, parent: fileContainingTheImport } ``` This is mainly for use by postcss runners that implement file watching. --- ## CONTRIBUTING * ⇄ Pull requests and ★ Stars are always welcome. * For bugs and feature requests, please create an issue. * Pull requests must be accompanied by passing automated tests (`$ npm test`). ## [Changelog](CHANGELOG.md) ## [License](LICENSE) postcss-import-15.0.1/index.js000077500000000000000000000312011434221453000162470ustar00rootroot00000000000000"use strict" // builtin tooling const path = require("path") // internal tooling const joinMedia = require("./lib/join-media") const joinLayer = require("./lib/join-layer") const resolveId = require("./lib/resolve-id") const loadContent = require("./lib/load-content") const processContent = require("./lib/process-content") const parseStatements = require("./lib/parse-statements") const assignLayerNames = require("./lib/assign-layer-names") function AtImport(options) { options = { root: process.cwd(), path: [], skipDuplicates: true, resolve: resolveId, load: loadContent, plugins: [], addModulesDirectories: [], nameLayer: null, ...options, } options.root = path.resolve(options.root) // convert string to an array of a single element if (typeof options.path === "string") options.path = [options.path] if (!Array.isArray(options.path)) options.path = [] options.path = options.path.map(p => path.resolve(options.root, p)) return { postcssPlugin: "postcss-import", Once(styles, { result, atRule, postcss }) { const state = { importedFiles: {}, hashFiles: {}, rootFilename: null, anonymousLayerCounter: 0, } if (styles.source?.input?.file) { state.rootFilename = styles.source.input.file state.importedFiles[styles.source.input.file] = {} } if (options.plugins && !Array.isArray(options.plugins)) { throw new Error("plugins option must be an array") } if (options.nameLayer && typeof options.nameLayer !== "function") { throw new Error("nameLayer option must be a function") } return parseStyles(result, styles, options, state, [], []).then( bundle => { applyRaws(bundle) applyMedia(bundle) applyStyles(bundle, styles) } ) function applyRaws(bundle) { bundle.forEach((stmt, index) => { if (index === 0) return if (stmt.parent) { const { before } = stmt.parent.node.raws if (stmt.type === "nodes") stmt.nodes[0].raws.before = before else stmt.node.raws.before = before } else if (stmt.type === "nodes") { stmt.nodes[0].raws.before = stmt.nodes[0].raws.before || "\n" } }) } function applyMedia(bundle) { bundle.forEach(stmt => { if ( (!stmt.media.length && !stmt.layer.length) || stmt.type === "charset" ) { return } if (stmt.layer.length > 1) { assignLayerNames(stmt.layer, stmt.node, state, options) } if (stmt.type === "import") { const parts = [stmt.fullUri] const media = stmt.media.join(", ") if (stmt.layer.length) { const layerName = stmt.layer.join(".") let layerParams = "layer" if (layerName) { layerParams = `layer(${layerName})` } parts.push(layerParams) } if (media) { parts.push(media) } stmt.node.params = parts.join(" ") } else if (stmt.type === "media") { if (stmt.layer.length) { const layerNode = atRule({ name: "layer", params: stmt.layer.join("."), source: stmt.node.source, }) if (stmt.parentMedia?.length) { const mediaNode = atRule({ name: "media", params: stmt.parentMedia.join(", "), source: stmt.node.source, }) mediaNode.append(layerNode) layerNode.append(stmt.node) stmt.node = mediaNode } else { layerNode.append(stmt.node) stmt.node = layerNode } } else { stmt.node.params = stmt.media.join(", ") } } else { const { nodes } = stmt const { parent } = nodes[0] let outerAtRule let innerAtRule if (stmt.media.length && stmt.layer.length) { const mediaNode = atRule({ name: "media", params: stmt.media.join(", "), source: parent.source, }) const layerNode = atRule({ name: "layer", params: stmt.layer.join("."), source: parent.source, }) mediaNode.append(layerNode) innerAtRule = layerNode outerAtRule = mediaNode } else if (stmt.media.length) { const mediaNode = atRule({ name: "media", params: stmt.media.join(", "), source: parent.source, }) innerAtRule = mediaNode outerAtRule = mediaNode } else if (stmt.layer.length) { const layerNode = atRule({ name: "layer", params: stmt.layer.join("."), source: parent.source, }) innerAtRule = layerNode outerAtRule = layerNode } parent.insertBefore(nodes[0], outerAtRule) // remove nodes nodes.forEach(node => { node.parent = undefined }) // better output nodes[0].raws.before = nodes[0].raws.before || "\n" // wrap new rules with media query and/or layer at rule innerAtRule.append(nodes) stmt.type = "media" stmt.node = outerAtRule delete stmt.nodes } }) } function applyStyles(bundle, styles) { styles.nodes = [] // Strip additional statements. bundle.forEach(stmt => { if (["charset", "import", "media"].includes(stmt.type)) { stmt.node.parent = undefined styles.append(stmt.node) } else if (stmt.type === "nodes") { stmt.nodes.forEach(node => { node.parent = undefined styles.append(node) }) } }) } function parseStyles(result, styles, options, state, media, layer) { const statements = parseStatements(result, styles) return Promise.resolve(statements) .then(stmts => { // process each statement in series return stmts.reduce((promise, stmt) => { return promise.then(() => { stmt.media = joinMedia(media, stmt.media || []) stmt.parentMedia = media stmt.layer = joinLayer(layer, stmt.layer || []) // skip protocol base uri (protocol://url) or protocol-relative if ( stmt.type !== "import" || /^(?:[a-z]+:)?\/\//i.test(stmt.uri) ) { return } if (options.filter && !options.filter(stmt.uri)) { // rejected by filter return } return resolveImportId(result, stmt, options, state) }) }, Promise.resolve()) }) .then(() => { let charset const imports = [] const bundle = [] function handleCharset(stmt) { if (!charset) charset = stmt // charsets aren't case-sensitive, so convert to lower case to compare else if ( stmt.node.params.toLowerCase() !== charset.node.params.toLowerCase() ) { throw new Error( `Incompatable @charset statements: ${stmt.node.params} specified in ${stmt.node.source.input.file} ${charset.node.params} specified in ${charset.node.source.input.file}` ) } } // squash statements and their children statements.forEach(stmt => { if (stmt.type === "charset") handleCharset(stmt) else if (stmt.type === "import") { if (stmt.children) { stmt.children.forEach((child, index) => { if (child.type === "import") imports.push(child) else if (child.type === "charset") handleCharset(child) else bundle.push(child) // For better output if (index === 0) child.parent = stmt }) } else imports.push(stmt) } else if (stmt.type === "media" || stmt.type === "nodes") { bundle.push(stmt) } }) return charset ? [charset, ...imports.concat(bundle)] : imports.concat(bundle) }) } function resolveImportId(result, stmt, options, state) { const atRule = stmt.node let sourceFile if (atRule.source?.input?.file) { sourceFile = atRule.source.input.file } const base = sourceFile ? path.dirname(atRule.source.input.file) : options.root return Promise.resolve(options.resolve(stmt.uri, base, options)) .then(paths => { if (!Array.isArray(paths)) paths = [paths] // Ensure that each path is absolute: return Promise.all( paths.map(file => { return !path.isAbsolute(file) ? resolveId(file, base, options) : file }) ) }) .then(resolved => { // Add dependency messages: resolved.forEach(file => { result.messages.push({ type: "dependency", plugin: "postcss-import", file, parent: sourceFile, }) }) return Promise.all( resolved.map(file => { return loadImportContent(result, stmt, file, options, state) }) ) }) .then(result => { // Merge loaded statements stmt.children = result.reduce((result, statements) => { return statements ? result.concat(statements) : result }, []) }) } function loadImportContent(result, stmt, filename, options, state) { const atRule = stmt.node const { media, layer } = stmt assignLayerNames(layer, atRule, state, options) if (options.skipDuplicates) { // skip files already imported at the same scope if (state.importedFiles[filename]?.[media]?.[layer]) { return } // save imported files to skip them next time if (!state.importedFiles[filename]) { state.importedFiles[filename] = {} } if (!state.importedFiles[filename][media]) { state.importedFiles[filename][media] = {} } state.importedFiles[filename][media][layer] = true } return Promise.resolve(options.load(filename, options)).then( content => { if (content.trim() === "") { result.warn(`${filename} is empty`, { node: atRule }) return } // skip previous imported files not containing @import rules if (state.hashFiles[content]?.[media]?.[layer]) { return } return processContent( result, content, filename, options, postcss ).then(importedResult => { const styles = importedResult.root result.messages = result.messages.concat(importedResult.messages) if (options.skipDuplicates) { const hasImport = styles.some(child => { return child.type === "atrule" && child.name === "import" }) if (!hasImport) { // save hash files to skip them next time if (!state.hashFiles[content]) { state.hashFiles[content] = {} } if (!state.hashFiles[content][media]) { state.hashFiles[content][media] = {} } state.hashFiles[content][media][layer] = true } } // recursion: import @import from imported file return parseStyles(result, styles, options, state, media, layer) }) } ) } }, } } AtImport.postcss = true module.exports = AtImport postcss-import-15.0.1/lib/000077500000000000000000000000001434221453000153505ustar00rootroot00000000000000postcss-import-15.0.1/lib/assign-layer-names.js000066400000000000000000000007221434221453000214060ustar00rootroot00000000000000"use strict" module.exports = function (layer, node, state, options) { layer.forEach((layerPart, i) => { if (layerPart.trim() === "") { if (options.nameLayer) { layer[i] = options .nameLayer(state.anonymousLayerCounter++, state.rootFilename) .toString() } else { throw node.error( `When using anonymous layers in @import you must also set the "nameLayer" plugin option` ) } } }) } postcss-import-15.0.1/lib/join-layer.js000066400000000000000000000004571434221453000177650ustar00rootroot00000000000000"use strict" module.exports = function (parentLayer, childLayer) { if (!parentLayer.length && childLayer.length) return childLayer if (parentLayer.length && !childLayer.length) return parentLayer if (!parentLayer.length && !childLayer.length) return [] return parentLayer.concat(childLayer) } postcss-import-15.0.1/lib/join-media.js000066400000000000000000000015501434221453000177230ustar00rootroot00000000000000"use strict" const startsWithKeywordRegexp = /^(all|not|only|print|screen)/i module.exports = function (parentMedia, childMedia) { if (!parentMedia.length && childMedia.length) return childMedia if (parentMedia.length && !childMedia.length) return parentMedia if (!parentMedia.length && !childMedia.length) return [] const media = [] parentMedia.forEach(parentItem => { const parentItemStartsWithKeyword = startsWithKeywordRegexp.test(parentItem) childMedia.forEach(childItem => { const childItemStartsWithKeyword = startsWithKeywordRegexp.test(childItem) if (parentItem !== childItem) { if (childItemStartsWithKeyword && !parentItemStartsWithKeyword) { media.push(`${childItem} and ${parentItem}`) } else { media.push(`${parentItem} and ${childItem}`) } } }) }) return media } postcss-import-15.0.1/lib/load-content.js000066400000000000000000000001611434221453000202730ustar00rootroot00000000000000"use strict" const readCache = require("read-cache") module.exports = filename => readCache(filename, "utf-8") postcss-import-15.0.1/lib/parse-statements.js000066400000000000000000000072751434221453000212200ustar00rootroot00000000000000"use strict" // external tooling const valueParser = require("postcss-value-parser") // extended tooling const { stringify } = valueParser function split(params, start) { const list = [] const last = params.reduce((item, node, index) => { if (index < start) return "" if (node.type === "div" && node.value === ",") { list.push(item) return "" } return item + stringify(node) }, "") list.push(last) return list } module.exports = function (result, styles) { const statements = [] let nodes = [] styles.each(node => { let stmt if (node.type === "atrule") { if (node.name === "import") stmt = parseImport(result, node) else if (node.name === "media") stmt = parseMedia(result, node) else if (node.name === "charset") stmt = parseCharset(result, node) } if (stmt) { if (nodes.length) { statements.push({ type: "nodes", nodes, media: [], layer: [], }) nodes = [] } statements.push(stmt) } else nodes.push(node) }) if (nodes.length) { statements.push({ type: "nodes", nodes, media: [], layer: [], }) } return statements } function parseMedia(result, atRule) { const params = valueParser(atRule.params).nodes return { type: "media", node: atRule, media: split(params, 0), layer: [], } } function parseCharset(result, atRule) { if (atRule.prev()) { return result.warn("@charset must precede all other statements", { node: atRule, }) } return { type: "charset", node: atRule, media: [], layer: [], } } function parseImport(result, atRule) { let prev = atRule.prev() if (prev) { do { if ( prev.type !== "comment" && (prev.type !== "atrule" || (prev.name !== "import" && prev.name !== "charset" && !(prev.name === "layer" && !prev.nodes))) ) { return result.warn( "@import must precede all other statements (besides @charset or empty @layer)", { node: atRule } ) } prev = prev.prev() } while (prev) } if (atRule.nodes) { return result.warn( "It looks like you didn't end your @import statement correctly. " + "Child nodes are attached to it.", { node: atRule } ) } const params = valueParser(atRule.params).nodes const stmt = { type: "import", node: atRule, media: [], layer: [], } // prettier-ignore if ( !params.length || ( params[0].type !== "string" || !params[0].value ) && ( params[0].type !== "function" || params[0].value !== "url" || !params[0].nodes.length || !params[0].nodes[0].value ) ) { return result.warn(`Unable to find uri in '${ atRule.toString() }'`, { node: atRule, }) } if (params[0].type === "string") stmt.uri = params[0].value else stmt.uri = params[0].nodes[0].value stmt.fullUri = stringify(params[0]) let remainder = params if (remainder.length > 2) { if ( (remainder[2].type === "word" || remainder[2].type === "function") && remainder[2].value === "layer" ) { if (remainder[1].type !== "space") { return result.warn("Invalid import layer statement", { node: atRule }) } if (remainder[2].nodes) { stmt.layer = [stringify(remainder[2].nodes)] } else { stmt.layer = [""] } remainder = remainder.slice(2) } } if (remainder.length > 2) { if (remainder[1].type !== "space") { return result.warn("Invalid import media statement", { node: atRule }) } stmt.media = split(remainder, 2) } return stmt } postcss-import-15.0.1/lib/process-content.js000066400000000000000000000024641434221453000210420ustar00rootroot00000000000000"use strict" // builtin tooling const path = require("path") // placeholder tooling let sugarss module.exports = function processContent( result, content, filename, options, postcss ) { const { plugins } = options const ext = path.extname(filename) const parserList = [] // SugarSS support: if (ext === ".sss") { if (!sugarss) { try { sugarss = require("sugarss") } catch {} // Ignore } if (sugarss) return runPostcss(postcss, content, filename, plugins, [sugarss]) } // Syntax support: if (result.opts.syntax?.parse) { parserList.push(result.opts.syntax.parse) } // Parser support: if (result.opts.parser) parserList.push(result.opts.parser) // Try the default as a last resort: parserList.push(null) return runPostcss(postcss, content, filename, plugins, parserList) } function runPostcss(postcss, content, filename, plugins, parsers, index) { if (!index) index = 0 return postcss(plugins) .process(content, { from: filename, parser: parsers[index], }) .catch(err => { // If there's an error, try the next parser index++ // If there are no parsers left, throw it if (index === parsers.length) throw err return runPostcss(postcss, content, filename, plugins, parsers, index) }) } postcss-import-15.0.1/lib/resolve-id.js000066400000000000000000000020061434221453000177550ustar00rootroot00000000000000"use strict" // external tooling const resolve = require("resolve") const moduleDirectories = ["web_modules", "node_modules"] function resolveModule(id, opts) { return new Promise((res, rej) => { resolve(id, opts, (err, path) => (err ? rej(err) : res(path))) }) } module.exports = function (id, base, options) { const paths = options.path const resolveOpts = { basedir: base, moduleDirectory: moduleDirectories.concat(options.addModulesDirectories), paths, extensions: [".css"], packageFilter: function processPackage(pkg) { if (pkg.style) pkg.main = pkg.style else if (!pkg.main || !/\.css$/.test(pkg.main)) pkg.main = "index.css" return pkg }, preserveSymlinks: false, } return resolveModule(`./${id}`, resolveOpts) .catch(() => resolveModule(id, resolveOpts)) .catch(() => { if (paths.indexOf(base) === -1) paths.unshift(base) throw new Error( `Failed to find '${id}' in [ ${paths.join(",\n ")} ]` ) }) } postcss-import-15.0.1/package.json000066400000000000000000000023761434221453000171000ustar00rootroot00000000000000{ "name": "postcss-import", "version": "15.0.1", "description": "PostCSS plugin to import CSS files", "keywords": [ "css", "postcss", "postcss-plugin", "import", "node modules", "npm" ], "author": "Maxime Thirouin", "license": "MIT", "repository": "https://github.com/postcss/postcss-import.git", "files": [ "index.js", "lib" ], "engines": { "node": ">=14.0.0" }, "dependencies": { "postcss-value-parser": "^4.0.0", "read-cache": "^1.0.0", "resolve": "^1.1.7" }, "devDependencies": { "ava": "^5.0.0", "eslint": "^8.2.0", "eslint-config-problems": "^7.0.0", "eslint-plugin-prettier": "^4.0.0", "postcss": "^8.0.0", "postcss-scss": "^4.0.0", "prettier": "~2.8.0", "sugarss": "^4.0.0" }, "peerDependencies": { "postcss": "^8.0.0" }, "scripts": { "ci": "eslint . && ava", "lint": "eslint . --fix", "pretest": "npm run lint", "test": "ava" }, "eslintConfig": { "extends": "eslint-config-problems", "env": { "node": true }, "plugins": [ "prettier" ], "rules": { "prettier/prettier": [ "error", { "semi": false, "arrowParens": "avoid" } ] } } } postcss-import-15.0.1/renovate.json000066400000000000000000000001321434221453000173140ustar00rootroot00000000000000{ "extends": [ "config:base", ":preserveSemverRanges", ":label(deps)" ] } postcss-import-15.0.1/test/000077500000000000000000000000001434221453000155615ustar00rootroot00000000000000postcss-import-15.0.1/test/custom-load.js000066400000000000000000000005721434221453000203520ustar00rootroot00000000000000"use strict" // external tooling const test = require("ava") // internal tooling const checkFixture = require("./helpers/check-fixture") test.serial("should accept content", checkFixture, "custom-load", { load: () => "custom-content {}", }) test.serial("should accept promised content", checkFixture, "custom-load", { load: () => Promise.resolve("custom-content {}"), }) postcss-import-15.0.1/test/custom-resolve.js000066400000000000000000000035311434221453000211100ustar00rootroot00000000000000"use strict" // builtin tooling const path = require("path") // external tooling const test = require("ava") const postcss = require("postcss") // plugin const atImport = require("..") // internal tooling const checkFixture = require("./helpers/check-fixture") test.serial("should accept file", checkFixture, "custom-resolve-file", { resolve: () => path.resolve("test/fixtures/imports/custom-resolve-1.css"), }) test.serial( "should accept promised file", checkFixture, "custom-resolve-file", { resolve: () => { return Promise.resolve( path.resolve("test/fixtures/imports/custom-resolve-1.css") ) }, } ) test.serial( "should accept array of files", checkFixture, "custom-resolve-array", { resolve: () => { return [ path.resolve("test/fixtures/imports/custom-resolve-1.css"), path.resolve("test/fixtures/imports/custom-resolve-2.css"), path.resolve("test/fixtures/imports/custom-resolve-1.css"), ] }, } ) test.serial( "should accept promised array of files", checkFixture, "custom-resolve-array", { resolve: () => { return Promise.resolve([ path.resolve("test/fixtures/imports/custom-resolve-1.css"), path.resolve("test/fixtures/imports/custom-resolve-2.css"), path.resolve("test/fixtures/imports/custom-resolve-1.css"), ]) }, } ) test("should apply default resolver when custom doesn't return an absolute path", t => { return postcss() .use( atImport({ resolve: path => path.replace("foo", "imports/bar"), load: p => { t.is(p, path.resolve("test/fixtures/imports", "bar.css")) return "/* comment */" }, }) ) .process(`@import "foo.css";`, { from: "test/fixtures/custom-resolve-file", }) .then(result => t.is(result.css, "/* comment */")) }) postcss-import-15.0.1/test/custom-syntax-parser.js000066400000000000000000000017431434221453000222540ustar00rootroot00000000000000"use strict" // external tooling const test = require("ava") const scss = require("postcss-scss") const sugarss = require("sugarss") // internal tooling const checkFixture = require("./helpers/check-fixture") test("should process custom syntax", checkFixture, "scss-syntax", null, { syntax: scss, }) test( "should process custom syntax by parser", checkFixture, "scss-parser", null, { parser: scss } ) test(".css importing .sss should work", checkFixture, "import-sss") test( ".sss importing .sss should work", checkFixture, { name: "sugar", ext: ".sss" }, null, { parser: sugarss } ) test( ".sss importing .css should work", checkFixture, { name: "sugar-import-css", ext: ".sss" }, null, { parser: sugarss } ) test( ".css importing .sss importing .css should work", checkFixture, "import-sss-css" ) test( ".sss importing .css importing .sss should work", checkFixture, { name: "import-css-sss", ext: ".sss" }, null, { parser: sugarss } ) postcss-import-15.0.1/test/filter.js000066400000000000000000000007131434221453000174050ustar00rootroot00000000000000"use strict" // external tooling const test = require("ava") // internal tooling const checkFixture = require("./helpers/check-fixture") test("should filter all imported stylesheets", checkFixture, "filter-all", { filter: () => false, }) test("should filter some stylesheets", checkFixture, "filter-some", { filter: url => url !== "foobar.css", }) test("shouldn't accept ignored stylesheets", checkFixture, "filter-ignore", { filter: () => true, }) postcss-import-15.0.1/test/fixtures/000077500000000000000000000000001434221453000174325ustar00rootroot00000000000000postcss-import-15.0.1/test/fixtures/charset-error.css000066400000000000000000000000621434221453000227220ustar00rootroot00000000000000@charset "foobar"; @import "imports/charset.css"; postcss-import-15.0.1/test/fixtures/charset-import.css000066400000000000000000000001561434221453000231070ustar00rootroot00000000000000@charset "UTF-8"; @import "test/fixtures/imports/foo.css"; @import "test/fixtures/imports/charset.css"; bar{} postcss-import-15.0.1/test/fixtures/charset-import.expected.css000066400000000000000000000000361434221453000247040ustar00rootroot00000000000000@charset "UTF-8"; foo{} bar{} postcss-import-15.0.1/test/fixtures/custom-load.css000066400000000000000000000000161434221453000223700ustar00rootroot00000000000000@import "foo" postcss-import-15.0.1/test/fixtures/custom-load.expected.css000066400000000000000000000000221434221453000241650ustar00rootroot00000000000000custom-content {} postcss-import-15.0.1/test/fixtures/custom-resolve-array.css000066400000000000000000000000241434221453000242430ustar00rootroot00000000000000@import "any-path"; postcss-import-15.0.1/test/fixtures/custom-resolve-array.expected.css000066400000000000000000000000501434221453000260420ustar00rootroot00000000000000custom-resolve-1 {} custom-resolve-2 {} postcss-import-15.0.1/test/fixtures/custom-resolve-file.css000066400000000000000000000000241434221453000240440ustar00rootroot00000000000000@import "any-path"; postcss-import-15.0.1/test/fixtures/custom-resolve-file.expected.css000066400000000000000000000000241434221453000256440ustar00rootroot00000000000000custom-resolve-1 {} postcss-import-15.0.1/test/fixtures/duplicates.css000066400000000000000000000003311434221453000222760ustar00rootroot00000000000000@import "foo.css"; @import "foo.css"; @import "foo-duplicate.css"; @import "foo.css" screen; @import "foo-duplicate2" screen; @import "proxy-file/index.css"; @import "proxy-file/sub-directory/index.css"; content{} postcss-import-15.0.1/test/fixtures/duplicates.expected.css000066400000000000000000000001351434221453000241000ustar00rootroot00000000000000foo{} foo{} foo{} @media screen{ foo{} } @media screen{ foo{} } proxy {} import {} content{} postcss-import-15.0.1/test/fixtures/empty-and-useless.css000066400000000000000000000000561434221453000235240ustar00rootroot00000000000000 @import "empty.css"; @import "useless.css"; postcss-import-15.0.1/test/fixtures/empty-and-useless.expected.css000066400000000000000000000000171434221453000253210ustar00rootroot00000000000000 /* useless */ postcss-import-15.0.1/test/fixtures/filter-all.css000066400000000000000000000005131434221453000221760ustar00rootroot00000000000000@import "foo.css"; @import "foo.css" screen; @import 'bar.css'; @import 'bar.css' screen; @import url(baz.css); @import url(baz.css) screen; @import url("foobar.css"); @import url("foobar.css") screen and (min-width: 25em); @import url('foobarbaz.css'); @import url('foobarbaz.css') print, screen and (min-width: 25em); content{} postcss-import-15.0.1/test/fixtures/filter-all.expected.css000066400000000000000000000005121434221453000237750ustar00rootroot00000000000000@import "foo.css"; @import "foo.css" screen; @import 'bar.css'; @import 'bar.css' screen; @import url(baz.css); @import url(baz.css) screen; @import url("foobar.css"); @import url("foobar.css") screen and (min-width: 25em); @import url('foobarbaz.css'); @import url('foobarbaz.css') print, screen and (min-width: 25em); content{} postcss-import-15.0.1/test/fixtures/filter-ignore.css000066400000000000000000000005551434221453000227170ustar00rootroot00000000000000@import "ignore.css" (min-width: 25em); @import "http://css"; @import "https://css"; @import 'http://css'; @import 'https://css'; @import url(http://css); @import url(https://css); @import url("http://css"); @import url("https://css"); @import url('http://css'); @import url('https://css'); @import url("//css"); @import url('//css'); @import url(//css); content{} postcss-import-15.0.1/test/fixtures/filter-ignore.expected.css000066400000000000000000000007141434221453000245140ustar00rootroot00000000000000@import "http://css" (min-width: 25em); @import "http://css-screen" screen and (min-width: 25em); @import "http://css"; @import "https://css"; @import 'http://css'; @import 'https://css'; @import url(http://css); @import url(https://css); @import url("http://css"); @import url("https://css"); @import url('http://css'); @import url('https://css'); @import url("//css"); @import url('//css'); @import url(//css); @media (min-width: 25em){ ignore{} } content{} postcss-import-15.0.1/test/fixtures/filter-some.css000066400000000000000000000005131434221453000223710ustar00rootroot00000000000000@import "foo.css"; @import "foo.css" screen; @import 'bar.css'; @import 'bar.css' screen; @import url(baz.css); @import url(baz.css) screen; @import url("foobar.css"); @import url("foobar.css") screen and (min-width: 25em); @import url('foobarbaz.css'); @import url('foobarbaz.css') print, screen and (min-width: 25em); content{} postcss-import-15.0.1/test/fixtures/filter-some.expected.css000066400000000000000000000003731434221453000241750ustar00rootroot00000000000000 @import url("foobar.css"); @import url("foobar.css") screen and (min-width: 25em); foo{} @media screen{ foo{} } bar{} @media screen{ bar{} } baz{} @media screen{ baz{} } foobarbaz{} @media print, screen and (min-width: 25em){ foobarbaz{} } content{} postcss-import-15.0.1/test/fixtures/ignore.css000066400000000000000000000010601434221453000214240ustar00rootroot00000000000000@import "ignore.css" (min-width: 25em); @import "http://css"; @import "https://css"; @import 'http://css'; @import 'https://css'; @import url(http://css); @import url(https://css); @import url("http://css"); @import url("https://css"); @import url('http://css'); @import url('https://css'); @import url("//css"); @import url('//css'); @import url(//css); @import "http://css" layer; @import "http://css" layer(bar); @import "http://css" layer screen and (min-width: 25em), print; @import "http://css" layer(bar) screen and (min-width: 25em), print; content{} postcss-import-15.0.1/test/fixtures/ignore.expected.css000066400000000000000000000012161434221453000232270ustar00rootroot00000000000000@import "http://css" (min-width: 25em); @import "http://css-screen" screen and (min-width: 25em); @import "http://css"; @import "https://css"; @import 'http://css'; @import 'https://css'; @import url(http://css); @import url(https://css); @import url("http://css"); @import url("https://css"); @import url('http://css'); @import url('https://css'); @import url("//css"); @import url('//css'); @import url(//css); @import "http://css" layer; @import "http://css" layer(bar); @import "http://css" layer screen and (min-width: 25em), print; @import "http://css" layer(bar) screen and (min-width: 25em), print; @media (min-width: 25em){ ignore{} } content{} postcss-import-15.0.1/test/fixtures/import-css-sss.expected.css000066400000000000000000000001101434221453000246420ustar00rootroot00000000000000.sugarbar{ color: blue } import.sugarbar{} .sugar{ color: white } postcss-import-15.0.1/test/fixtures/import-css-sss.sss000066400000000000000000000000651434221453000230730ustar00rootroot00000000000000@import "import-sugarbar.css" .sugar color: white postcss-import-15.0.1/test/fixtures/import-sss-css.css000066400000000000000000000000351434221453000230500ustar00rootroot00000000000000@import "foo-recursive.sss"; postcss-import-15.0.1/test/fixtures/import-sss-css.expected.css000066400000000000000000000000451434221453000246510ustar00rootroot00000000000000bar{} foo.recursive{ color: red } postcss-import-15.0.1/test/fixtures/import-sss.css000066400000000000000000000000301434221453000222550ustar00rootroot00000000000000@import "sugarbar.sss"; postcss-import-15.0.1/test/fixtures/import-sss.expected.css000066400000000000000000000000341434221453000240610ustar00rootroot00000000000000.sugarbar { color: blue } postcss-import-15.0.1/test/fixtures/imports/000077500000000000000000000000001434221453000211275ustar00rootroot00000000000000postcss-import-15.0.1/test/fixtures/imports/bar-decl.css000066400000000000000000000000411434221453000233050ustar00rootroot00000000000000body { bar: bar; qux: qux; } postcss-import-15.0.1/test/fixtures/imports/bar.css000077500000000000000000000000061434221453000224040ustar00rootroot00000000000000bar{} postcss-import-15.0.1/test/fixtures/imports/bar/000077500000000000000000000000001434221453000216735ustar00rootroot00000000000000postcss-import-15.0.1/test/fixtures/imports/bar/baz.css000066400000000000000000000000071434221453000231560ustar00rootroot00000000000000bar {} postcss-import-15.0.1/test/fixtures/imports/bar/index.css000066400000000000000000000000221434221453000235060ustar00rootroot00000000000000@import "baz.css" postcss-import-15.0.1/test/fixtures/imports/barbaz.css000077500000000000000000000000111434221453000230750ustar00rootroot00000000000000barbaz{} postcss-import-15.0.1/test/fixtures/imports/baz.css000077500000000000000000000000061434221453000224140ustar00rootroot00000000000000baz{} postcss-import-15.0.1/test/fixtures/imports/charset-content.css000066400000000000000000000000461434221453000247420ustar00rootroot00000000000000@charset "UTF-8"; .charset-content {} postcss-import-15.0.1/test/fixtures/imports/charset.css000066400000000000000000000000221434221453000232640ustar00rootroot00000000000000@charset "UTF-8"; postcss-import-15.0.1/test/fixtures/imports/custom-resolve-1.css000066400000000000000000000000241434221453000247620ustar00rootroot00000000000000custom-resolve-1 {} postcss-import-15.0.1/test/fixtures/imports/custom-resolve-2.css000066400000000000000000000000241434221453000247630ustar00rootroot00000000000000custom-resolve-2 {} postcss-import-15.0.1/test/fixtures/imports/empty.css000066400000000000000000000000001434221453000227650ustar00rootroot00000000000000postcss-import-15.0.1/test/fixtures/imports/foo-decl.css000066400000000000000000000000411434221453000233240ustar00rootroot00000000000000body { foo: foo; baz: baz; } postcss-import-15.0.1/test/fixtures/imports/foo-duplicate.css000066400000000000000000000000061434221453000243700ustar00rootroot00000000000000foo{} postcss-import-15.0.1/test/fixtures/imports/foo-duplicate2.css000066400000000000000000000000061434221453000244520ustar00rootroot00000000000000foo{} postcss-import-15.0.1/test/fixtures/imports/foo-first.css000066400000000000000000000000571434221453000235530ustar00rootroot00000000000000@import "bar.css"; foo.first{ color: red; } postcss-import-15.0.1/test/fixtures/imports/foo-layered.css000077500000000000000000000000301434221453000240430ustar00rootroot00000000000000@layer foo { foo {} } postcss-import-15.0.1/test/fixtures/imports/foo-recursive.css000077500000000000000000000000441434221453000244320ustar00rootroot00000000000000@import "bar.css"; foo.recursive{} postcss-import-15.0.1/test/fixtures/imports/foo-recursive.sss000066400000000000000000000000561434221453000244520ustar00rootroot00000000000000@import "bar.css" foo.recursive color: red postcss-import-15.0.1/test/fixtures/imports/foo-second.css000066400000000000000000000000611434221453000236720ustar00rootroot00000000000000@import "bar.css"; foo.second{ color: blue; } postcss-import-15.0.1/test/fixtures/imports/foo.css000077500000000000000000000000061434221453000224230ustar00rootroot00000000000000foo{} postcss-import-15.0.1/test/fixtures/imports/foo/000077500000000000000000000000001434221453000217125ustar00rootroot00000000000000postcss-import-15.0.1/test/fixtures/imports/foo/baz.css000066400000000000000000000000071434221453000231750ustar00rootroot00000000000000foo {} postcss-import-15.0.1/test/fixtures/imports/foo/index.css000066400000000000000000000000221434221453000235250ustar00rootroot00000000000000@import "baz.css" postcss-import-15.0.1/test/fixtures/imports/foobar.css000077500000000000000000000000111434221453000231040ustar00rootroot00000000000000foobar{} postcss-import-15.0.1/test/fixtures/imports/foobarbaz.css000077500000000000000000000000141434221453000236040ustar00rootroot00000000000000foobarbaz{} postcss-import-15.0.1/test/fixtures/imports/ignore.css000066400000000000000000000001031434221453000231160ustar00rootroot00000000000000@import "http://css"; @import "http://css-screen" screen; ignore{} postcss-import-15.0.1/test/fixtures/imports/import-missing.css000077500000000000000000000000411434221453000246200ustar00rootroot00000000000000 @import "missing-file.css"; postcss-import-15.0.1/test/fixtures/imports/import-sugarbar.css000066400000000000000000000000531434221453000247550ustar00rootroot00000000000000@import "sugarbar.sss"; import.sugarbar{} postcss-import-15.0.1/test/fixtures/imports/inline-comment.scss000066400000000000000000000000221434221453000247340ustar00rootroot00000000000000// inline comment postcss-import-15.0.1/test/fixtures/imports/layer-anonymous.css000066400000000000000000000005431434221453000250050ustar00rootroot00000000000000@import url("layer-level-2-anonymous.css") layer; body { order: 1; } @media (min-width: 50rem) { body { order: 2; } } @keyframes RED_TO_BLUE { 0% { background-color: red; } 100% { background-color: blue; } } @supports (display: grid) { body { display: grid; order: 3; } } @layer A { body { order: 4; } } postcss-import-15.0.1/test/fixtures/imports/layer-level-2-anonymous.css000066400000000000000000000002521434221453000262460ustar00rootroot00000000000000@import "http://css" layer; @import "http://css-bar" layer(bar); @import url("layer-level-3.css") layer (min-width: 320px); @layer Y { body { color: purple; } } postcss-import-15.0.1/test/fixtures/imports/layer-level-2.css000066400000000000000000000001621434221453000242200ustar00rootroot00000000000000@import url("layer-level-3.css") layer(level-3) (min-width: 320px); @layer Y { body { color: purple; } } postcss-import-15.0.1/test/fixtures/imports/layer-level-3.css000066400000000000000000000000531434221453000242200ustar00rootroot00000000000000@layer Z { body { color: cyan; } } postcss-import-15.0.1/test/fixtures/imports/layer-rule-grouping.css000066400000000000000000000001631434221453000255520ustar00rootroot00000000000000rule-one {} rule-two {} @media (min-width: 50rem) { rule-three {} rule-four {} } rule-five {} rule-six {} postcss-import-15.0.1/test/fixtures/imports/layer.css000066400000000000000000000005421434221453000227560ustar00rootroot00000000000000@import url("layer-level-2.css") layer(level-2); body { order: 1; } @media (min-width: 50rem) { body { order: 2; } } @keyframes RED_TO_BLUE { 0% { background-color: red; } 100% { background-color: blue; } } @supports (display: grid) { body { display: grid; order: 3; } } @layer A { body { order: 4; } } postcss-import-15.0.1/test/fixtures/imports/media-content-level-2.css000066400000000000000000000000551434221453000256340ustar00rootroot00000000000000@import "media-content-level-3"; level-2 {} postcss-import-15.0.1/test/fixtures/imports/media-content-level-3.css000066400000000000000000000000131434221453000256270ustar00rootroot00000000000000level-3 {} postcss-import-15.0.1/test/fixtures/imports/media-import-level-2.css000066400000000000000000000000771434221453000255000ustar00rootroot00000000000000@import "media-import-level-3" level-2; @import "//" level-2; postcss-import-15.0.1/test/fixtures/imports/media-import-level-3.css000066400000000000000000000000261434221453000254730ustar00rootroot00000000000000@import "//" level-3; postcss-import-15.0.1/test/fixtures/imports/media-join-nested.css000066400000000000000000000001271434221453000251350ustar00rootroot00000000000000@media one-2 {} @media or-left-2, or-right-2 {} @media and-left-2 and and-right-2 {} postcss-import-15.0.1/test/fixtures/imports/media-query-level-2.css000066400000000000000000000000721434221453000253260ustar00rootroot00000000000000@import "media-query-level-3" level-2; @media level-2 {} postcss-import-15.0.1/test/fixtures/imports/media-query-level-3.css000066400000000000000000000000221434221453000253220ustar00rootroot00000000000000@media level-3 {} postcss-import-15.0.1/test/fixtures/imports/modules/000077500000000000000000000000001434221453000225775ustar00rootroot00000000000000postcss-import-15.0.1/test/fixtures/imports/modules/empty/000077500000000000000000000000001434221453000237355ustar00rootroot00000000000000postcss-import-15.0.1/test/fixtures/imports/modules/empty/index.css000066400000000000000000000000111434221453000255460ustar00rootroot00000000000000empty {} postcss-import-15.0.1/test/fixtures/imports/modules/empty/package.json000066400000000000000000000000031434221453000262140ustar00rootroot00000000000000{} postcss-import-15.0.1/test/fixtures/imports/modules/main-js/000077500000000000000000000000001434221453000241355ustar00rootroot00000000000000postcss-import-15.0.1/test/fixtures/imports/modules/main-js/index.css000066400000000000000000000000131434221453000257500ustar00rootroot00000000000000main-js {} postcss-import-15.0.1/test/fixtures/imports/modules/main-js/main.js000066400000000000000000000000411434221453000254120ustar00rootroot00000000000000"use strict" module.exports = {} postcss-import-15.0.1/test/fixtures/imports/modules/main-js/package.json000066400000000000000000000000301434221453000264140ustar00rootroot00000000000000{ "main": "main.js" } postcss-import-15.0.1/test/fixtures/imports/modules/main-style/000077500000000000000000000000001434221453000246615ustar00rootroot00000000000000postcss-import-15.0.1/test/fixtures/imports/modules/main-style/main.css000066400000000000000000000000201434221453000263070ustar00rootroot00000000000000style-mained {} postcss-import-15.0.1/test/fixtures/imports/modules/main-style/package.json000066400000000000000000000000611434221453000271440ustar00rootroot00000000000000{ "main": "main.css", "style": "style.css" } postcss-import-15.0.1/test/fixtures/imports/modules/main-style/style.css000066400000000000000000000000171434221453000265310ustar00rootroot00000000000000main-styled {} postcss-import-15.0.1/test/fixtures/imports/modules/main/000077500000000000000000000000001434221453000235235ustar00rootroot00000000000000postcss-import-15.0.1/test/fixtures/imports/modules/main/main.css000066400000000000000000000000101434221453000251500ustar00rootroot00000000000000main {} postcss-import-15.0.1/test/fixtures/imports/modules/main/package.json000066400000000000000000000000311434221453000260030ustar00rootroot00000000000000{ "main": "main.css" } postcss-import-15.0.1/test/fixtures/imports/modules/simple/000077500000000000000000000000001434221453000240705ustar00rootroot00000000000000postcss-import-15.0.1/test/fixtures/imports/modules/simple/index.css000066400000000000000000000000121434221453000257020ustar00rootroot00000000000000simple {} postcss-import-15.0.1/test/fixtures/imports/modules/style/000077500000000000000000000000001434221453000237375ustar00rootroot00000000000000postcss-import-15.0.1/test/fixtures/imports/modules/style/package.json000066400000000000000000000000331434221453000262210ustar00rootroot00000000000000{ "style": "style.css" } postcss-import-15.0.1/test/fixtures/imports/modules/style/style.css000066400000000000000000000000111434221453000256010ustar00rootroot00000000000000style {} postcss-import-15.0.1/test/fixtures/imports/proxy-file/000077500000000000000000000000001434221453000232255ustar00rootroot00000000000000postcss-import-15.0.1/test/fixtures/imports/proxy-file/index.css000066400000000000000000000000341434221453000250430ustar00rootroot00000000000000@import "./proxy-file.css"; postcss-import-15.0.1/test/fixtures/imports/proxy-file/proxy-file.css000066400000000000000000000000111434221453000260250ustar00rootroot00000000000000proxy {} postcss-import-15.0.1/test/fixtures/imports/proxy-file/sub-directory/000077500000000000000000000000001434221453000260205ustar00rootroot00000000000000postcss-import-15.0.1/test/fixtures/imports/proxy-file/sub-directory/index.css000066400000000000000000000000341434221453000276360ustar00rootroot00000000000000@import "./proxy-file.css"; postcss-import-15.0.1/test/fixtures/imports/proxy-file/sub-directory/proxy-file.css000066400000000000000000000000121434221453000306210ustar00rootroot00000000000000import {} postcss-import-15.0.1/test/fixtures/imports/qux.css000077500000000000000000000000361434221453000224600ustar00rootroot00000000000000quux{ not: "relative/qux" } postcss-import-15.0.1/test/fixtures/imports/sugarbar.sss000066400000000000000000000000301434221453000234600ustar00rootroot00000000000000.sugarbar color: blue postcss-import-15.0.1/test/fixtures/imports/syntax-error.css000066400000000000000000000000621434221453000243140ustar00rootroot00000000000000body { bar: bar; qux: qux; a { foo: foo; } postcss-import-15.0.1/test/fixtures/imports/useless.css000066400000000000000000000000171434221453000233220ustar00rootroot00000000000000 /* useless */ postcss-import-15.0.1/test/fixtures/layer-import-atrules-anonymous.css000066400000000000000000000002751434221453000262770ustar00rootroot00000000000000@import url("layer-anonymous.css") layer screen; @import url("layer-anonymous.css") layer; @import url("layer-anonymous.css") layer(named-layer-1); @import "http://css-top-level" layer; postcss-import-15.0.1/test/fixtures/layer-import-atrules-anonymous.expected.css000066400000000000000000000046671434221453000301100ustar00rootroot00000000000000@import "http://css" layer(import-anon-layer-0.import-anon-layer-1.import-anon-layer-8) screen; @import "http://css-bar" layer(import-anon-layer-0.import-anon-layer-1.bar) screen; @import "http://css" layer(import-anon-layer-3.import-anon-layer-4.import-anon-layer-9); @import "http://css-bar" layer(import-anon-layer-3.import-anon-layer-4.bar); @import "http://css" layer(named-layer-1.import-anon-layer-6.import-anon-layer-10); @import "http://css-bar" layer(named-layer-1.import-anon-layer-6.bar); @import "http://css-top-level" layer; @media screen and (min-width: 320px){ @layer import-anon-layer-0.import-anon-layer-1.import-anon-layer-2{ @layer Z { body { color: cyan; } } } } @media screen{ @layer import-anon-layer-0.import-anon-layer-1{ @layer Y { body { color: purple; } } } } @media screen{ @layer import-anon-layer-0{ body { order: 1; } } } @media screen{ @layer import-anon-layer-0{ @media (min-width: 50rem) { body { order: 2; } } } } @media screen{ @layer import-anon-layer-0{ @keyframes RED_TO_BLUE { 0% { background-color: red; } 100% { background-color: blue; } } @supports (display: grid) { body { display: grid; order: 3; } } @layer A { body { order: 4; } } } } @media (min-width: 320px){ @layer import-anon-layer-3.import-anon-layer-4.import-anon-layer-5{ @layer Z { body { color: cyan; } } } } @layer import-anon-layer-3.import-anon-layer-4{ @layer Y { body { color: purple; } } } @layer import-anon-layer-3{ body { order: 1; } } @layer import-anon-layer-3{ @media (min-width: 50rem) { body { order: 2; } } } @layer import-anon-layer-3{ @keyframes RED_TO_BLUE { 0% { background-color: red; } 100% { background-color: blue; } } @supports (display: grid) { body { display: grid; order: 3; } } @layer A { body { order: 4; } } } @media (min-width: 320px){ @layer named-layer-1.import-anon-layer-6.import-anon-layer-7{ @layer Z { body { color: cyan; } } } } @layer named-layer-1.import-anon-layer-6{ @layer Y { body { color: purple; } } } @layer named-layer-1{ body { order: 1; } } @layer named-layer-1{ @media (min-width: 50rem) { body { order: 2; } } } @layer named-layer-1{ @keyframes RED_TO_BLUE { 0% { background-color: red; } 100% { background-color: blue; } } @supports (display: grid) { body { display: grid; order: 3; } } @layer A { body { order: 4; } } } postcss-import-15.0.1/test/fixtures/layer-import-atrules.css000066400000000000000000000001651434221453000242470ustar00rootroot00000000000000@import url("layer.css") layer(imported-with-media) screen; @import url("layer.css") layer(imported-without-media); postcss-import-15.0.1/test/fixtures/layer-import-atrules.expected.css000066400000000000000000000024411434221453000260460ustar00rootroot00000000000000@media screen and (min-width: 320px) { @layer imported-with-media.level-2.level-3 { @layer Z { body { color: cyan; } } } } @media screen { @layer imported-with-media.level-2 { @layer Y { body { color: purple; } } } } @media screen { @layer imported-with-media { body { order: 1; } } } @media screen { @layer imported-with-media { @media (min-width: 50rem) { body { order: 2; } } } } @media screen { @layer imported-with-media { @keyframes RED_TO_BLUE { 0% { background-color: red; } 100% { background-color: blue; } } @supports (display: grid) { body { display: grid; order: 3; } } @layer A { body { order: 4; } } } } @media (min-width: 320px) { @layer imported-without-media.level-2.level-3 { @layer Z { body { color: cyan; } } } } @layer imported-without-media.level-2 { @layer Y { body { color: purple; } } } @layer imported-without-media { body { order: 1; } } @layer imported-without-media { @media (min-width: 50rem) { body { order: 2; } } } @layer imported-without-media { @keyframes RED_TO_BLUE { 0% { background-color: red; } 100% { background-color: blue; } } @supports (display: grid) { body { display: grid; order: 3; } } @layer A { body { order: 4; } } } postcss-import-15.0.1/test/fixtures/layer-rule-grouping.css000066400000000000000000000003021434221453000240500ustar00rootroot00000000000000@import url("layer-rule-grouping.css") screen; @import url("layer-rule-grouping.css") layer; @import url("layer-rule-grouping.css") layer; @import url("layer-rule-grouping.css") layer(named); postcss-import-15.0.1/test/fixtures/layer-rule-grouping.expected.css000066400000000000000000000013661434221453000256630ustar00rootroot00000000000000@media screen { rule-one {} rule-two {} } @media screen and (min-width: 50rem) { rule-three {} rule-four {} } @media screen { rule-five {} rule-six {} } @layer import-anon-layer-0 { rule-one {} rule-two {} } @layer import-anon-layer-0 { @media (min-width: 50rem) { rule-three {} rule-four {} } } @layer import-anon-layer-0 { rule-five {} rule-six {} } @layer import-anon-layer-1 { rule-one {} rule-two {} } @layer import-anon-layer-1 { @media (min-width: 50rem) { rule-three {} rule-four {} } } @layer import-anon-layer-1 { rule-five {} rule-six {} } @layer named { rule-one {} rule-two {} } @layer named { @media (min-width: 50rem) { rule-three {} rule-four {} } } @layer named { rule-five {} rule-six {} } postcss-import-15.0.1/test/fixtures/layer.css000066400000000000000000000004331434221453000212600ustar00rootroot00000000000000@layer layer-alpha, layer-beta.one; @import "foo.css" layer(foo); @import 'bar.css' layer(bar); @import 'bar.css' layer(bar) level-1 and level-2; @import url(baz.css) layer(baz); @import url("foobar.css") layer(foobar); @import url("foo-layered.css") layer(foo-layered); content{} postcss-import-15.0.1/test/fixtures/layer.expected.css000066400000000000000000000003441434221453000230610ustar00rootroot00000000000000@layer layer-alpha, layer-beta.one; @layer foo{ foo{} } @layer bar{ bar{} } @media level-1 and level-2{ @layer bar{ bar{} } } @layer baz{ baz{} } @layer foobar{ foobar{} } @layer foo-layered{ @layer foo { foo {} } } content{} postcss-import-15.0.1/test/fixtures/media-charset.css000066400000000000000000000000431434221453000226470ustar00rootroot00000000000000@import "charset-content" level-1; postcss-import-15.0.1/test/fixtures/media-charset.expected.css000066400000000000000000000000701434221453000244470ustar00rootroot00000000000000@charset "UTF-8"; @media level-1{ .charset-content {} } postcss-import-15.0.1/test/fixtures/media-content.css000066400000000000000000000000651434221453000226740ustar00rootroot00000000000000@import "media-content-level-2" level-1; level-1 {} postcss-import-15.0.1/test/fixtures/media-content.expected.css000066400000000000000000000001121434221453000244650ustar00rootroot00000000000000@media level-1 { level-3 {} } @media level-1 { level-2 {} } level-1 {} postcss-import-15.0.1/test/fixtures/media-import.css000066400000000000000000000000771434221453000225370ustar00rootroot00000000000000@import "media-import-level-2" level-1; @import "//" level-1; postcss-import-15.0.1/test/fixtures/media-import.expected.css000066400000000000000000000001501434221453000243270ustar00rootroot00000000000000@import "//" level-1 and level-2 and level-3; @import "//" level-1 and level-2; @import "//" level-1; postcss-import-15.0.1/test/fixtures/media-join.css000066400000000000000000000002321434221453000221550ustar00rootroot00000000000000@import "media-join-nested.css" one-1; @import "media-join-nested.css" or-left-1, or-right-1; @import "media-join-nested.css" and-left-1 and and-right-1; postcss-import-15.0.1/test/fixtures/media-join.expected.css000066400000000000000000000011311434221453000237540ustar00rootroot00000000000000@media one-1 and one-2 {} @media one-1 and or-left-2, one-1 and or-right-2 {} @media one-1 and and-left-2 and and-right-2 {} @media or-left-1 and one-2, or-right-1 and one-2 {} @media or-left-1 and or-left-2, or-left-1 and or-right-2, or-right-1 and or-left-2, or-right-1 and or-right-2 {} @media or-left-1 and and-left-2 and and-right-2, or-right-1 and and-left-2 and and-right-2 {} @media and-left-1 and and-right-1 and one-2 {} @media and-left-1 and and-right-1 and or-left-2, and-left-1 and and-right-1 and or-right-2 {} @media and-left-1 and and-right-1 and and-left-2 and and-right-2 {} postcss-import-15.0.1/test/fixtures/media-query.css000066400000000000000000000000721434221453000223650ustar00rootroot00000000000000@import "media-query-level-2" level-1; @media level-1 {} postcss-import-15.0.1/test/fixtures/media-query.expected.css000066400000000000000000000001341434221453000241640ustar00rootroot00000000000000@media level-1 and level-2 and level-3 {} @media level-1 and level-2 {} @media level-1 {} postcss-import-15.0.1/test/fixtures/no-duplicate.css000066400000000000000000000003311434221453000225250ustar00rootroot00000000000000@import "foo.css"; @import "foo.css"; @import "foo-duplicate.css"; @import "foo.css" screen; @import "foo-duplicate2" screen; @import "proxy-file/index.css"; @import "proxy-file/sub-directory/index.css"; content{} postcss-import-15.0.1/test/fixtures/no-duplicate.expected.css000066400000000000000000000000721434221453000243270ustar00rootroot00000000000000foo{} @media screen{ foo{} } proxy {} import {} content{} postcss-import-15.0.1/test/fixtures/order.css000066400000000000000000000001151434221453000212540ustar00rootroot00000000000000@import "foo-first.css"; @import "foo-second.css"; .baz { color: green; } postcss-import-15.0.1/test/fixtures/order.expected.css000066400000000000000000000001321434221453000230530ustar00rootroot00000000000000bar{} foo.first{ color: red; } foo.second{ color: blue; } .baz { color: green; } postcss-import-15.0.1/test/fixtures/plugins.css000066400000000000000000000001101434221453000216150ustar00rootroot00000000000000@import 'foo/index.css'; @import 'bar.css'; @level-1-1 {} @level-1-2 {} postcss-import-15.0.1/test/fixtures/plugins.expected.css000066400000000000000000000000551434221453000234250ustar00rootroot00000000000000foo-converted {} @level-1-1 {} @level-1-2 {} postcss-import-15.0.1/test/fixtures/resolve-custom-modules.css000066400000000000000000000003021434221453000245740ustar00rootroot00000000000000@import "shared-fake"; @import "shared-auto"; @import "shared-nest"; @import "shared-by-hand/style.css"; @import "shared-use-dep"; @import "shared-use-dep-too"; @import "shared-use-dep" screen; postcss-import-15.0.1/test/fixtures/resolve-custom-modules.expected.css000066400000000000000000000001551434221453000264020ustar00rootroot00000000000000.shared-fake{} .shared-auto{} .shared-nested{} .shared-byHand{} .shared-dep{} @media screen{ .shared-dep{} } postcss-import-15.0.1/test/fixtures/resolve-cwd.css000066400000000000000000000001341434221453000223740ustar00rootroot00000000000000@import "test/fixtures/imports/foo.css"; @import "test/fixtures/imports/foo-recursive.css"; postcss-import-15.0.1/test/fixtures/resolve-cwd.expected.css000066400000000000000000000000341434221453000241730ustar00rootroot00000000000000foo{} bar{} foo.recursive{} postcss-import-15.0.1/test/fixtures/resolve-from.css000066400000000000000000000001001434221453000225530ustar00rootroot00000000000000@import "imports/foo.css"; @import "imports/foo-recursive.css"; postcss-import-15.0.1/test/fixtures/resolve-from.expected.css000066400000000000000000000000341434221453000243610ustar00rootroot00000000000000foo{} bar{} foo.recursive{} postcss-import-15.0.1/test/fixtures/resolve-local-modules.css000066400000000000000000000004411434221453000243600ustar00rootroot00000000000000@import "test/fixtures/imports/modules/simple"; @import "test/fixtures/imports/modules/empty"; @import "test/fixtures/imports/modules/style"; @import "test/fixtures/imports/modules/main"; @import "test/fixtures/imports/modules/main-js"; @import "test/fixtures/imports/modules/main-style"; postcss-import-15.0.1/test/fixtures/resolve-local-modules.expected.css000066400000000000000000000000761434221453000261640ustar00rootroot00000000000000simple {} empty {} style {} main {} main-js {} main-styled {} postcss-import-15.0.1/test/fixtures/resolve-modules.css000066400000000000000000000004771434221453000233010ustar00rootroot00000000000000@import "fake"; @import "auto"; @import "nest"; @import "by-hand/style.css"; @import "use-dep"; @import "use-dep-too"; @import "use-dep" screen; @import "web-fake"; @import "web-auto"; @import "web-nest"; @import "web-by-hand/style.css"; @import "web-use-dep"; @import "web-use-dep-too"; @import "web-use-dep" screen; postcss-import-15.0.1/test/fixtures/resolve-modules.expected.css000066400000000000000000000002361434221453000250720ustar00rootroot00000000000000.fake{} .auto{} .nested{} .byHand{} .dep{} @media screen{ .dep{} } .web-fake{} .web-auto{} .web-nested{} .web-byHand{} .web-dep{} @media screen{ .web-dep{} } postcss-import-15.0.1/test/fixtures/resolve-npm-subpackages.css000066400000000000000000000001151434221453000246760ustar00rootroot00000000000000@import "modularized-css/foo"; @import "modularized-css/foo/boo/boomod.css"; postcss-import-15.0.1/test/fixtures/resolve-npm-subpackages.expected.css000066400000000000000000000000441434221453000264770ustar00rootroot00000000000000.i-pity-the-foo{} .i-pity-the-boo{} postcss-import-15.0.1/test/fixtures/resolve-path-cwd.css000066400000000000000000000000601434221453000233240ustar00rootroot00000000000000@import "foo.css"; @import "foo-recursive.css"; postcss-import-15.0.1/test/fixtures/resolve-path-cwd.expected.css000066400000000000000000000000341434221453000251250ustar00rootroot00000000000000foo{} bar{} foo.recursive{} postcss-import-15.0.1/test/fixtures/resolve-path-modules.css000066400000000000000000000001551434221453000242240ustar00rootroot00000000000000@import "simple"; @import "empty"; @import "style"; @import "main"; @import "main-js"; @import "main-style"; postcss-import-15.0.1/test/fixtures/resolve-path-modules.expected.css000066400000000000000000000000761434221453000260260ustar00rootroot00000000000000simple {} empty {} style {} main {} main-js {} main-styled {} postcss-import-15.0.1/test/fixtures/resolve-path-root.css000066400000000000000000000000601434221453000235320ustar00rootroot00000000000000@import "foo.css"; @import "foo-recursive.css"; postcss-import-15.0.1/test/fixtures/resolve-path-root.expected.css000066400000000000000000000000341434221453000253330ustar00rootroot00000000000000foo{} bar{} foo.recursive{} postcss-import-15.0.1/test/fixtures/resolve-root.css000066400000000000000000000001001434221453000225730ustar00rootroot00000000000000@import "imports/foo.css"; @import "imports/foo-recursive.css"; postcss-import-15.0.1/test/fixtures/resolve-root.expected.css000066400000000000000000000000341434221453000244010ustar00rootroot00000000000000foo{} bar{} foo.recursive{} postcss-import-15.0.1/test/fixtures/same.css000066400000000000000000000000621434221453000210670ustar00rootroot00000000000000@import "foo/index.css"; @import "bar/index.css"; postcss-import-15.0.1/test/fixtures/same.expected.css000066400000000000000000000000161434221453000226660ustar00rootroot00000000000000foo {} bar {} postcss-import-15.0.1/test/fixtures/scss-parser.css000066400000000000000000000000371434221453000224110ustar00rootroot00000000000000@import "inline-comment.scss"; postcss-import-15.0.1/test/fixtures/scss-parser.expected.css000066400000000000000000000000241434221453000242050ustar00rootroot00000000000000/* inline comment*/ postcss-import-15.0.1/test/fixtures/scss-syntax.css000066400000000000000000000000371434221453000224430ustar00rootroot00000000000000@import "inline-comment.scss"; postcss-import-15.0.1/test/fixtures/scss-syntax.expected.css000066400000000000000000000000221434221453000242350ustar00rootroot00000000000000// inline comment postcss-import-15.0.1/test/fixtures/simple.css000077500000000000000000000005131434221453000214370ustar00rootroot00000000000000@import "foo.css"; @import "foo.css" screen; @import 'bar.css'; @import 'bar.css' screen; @import url(baz.css); @import url(baz.css) screen; @import url("foobar.css"); @import url("foobar.css") screen and (min-width: 25em); @import url('foobarbaz.css'); @import url('foobarbaz.css') print, screen and (min-width: 25em); content{} postcss-import-15.0.1/test/fixtures/simple.expected.css000077500000000000000000000003401434221453000232350ustar00rootroot00000000000000foo{} @media screen{ foo{} } bar{} @media screen{ bar{} } baz{} @media screen{ baz{} } foobar{} @media screen and (min-width: 25em){ foobar{} } foobarbaz{} @media print, screen and (min-width: 25em){ foobarbaz{} } content{} postcss-import-15.0.1/test/fixtures/sugar-import-css.expected.css000066400000000000000000000000371434221453000251630ustar00rootroot00000000000000bar{} .sugar{ color: white } postcss-import-15.0.1/test/fixtures/sugar-import-css.sss000066400000000000000000000000501434221453000233760ustar00rootroot00000000000000@import "bar.css" .sugar color: white postcss-import-15.0.1/test/fixtures/sugar.expected.css000066400000000000000000000000661434221453000230670ustar00rootroot00000000000000.sugarbar { color: blue } .sugar { color: white } postcss-import-15.0.1/test/fixtures/sugar.sss000066400000000000000000000000551434221453000213050ustar00rootroot00000000000000@import "sugarbar.sss" .sugar color: white postcss-import-15.0.1/test/fixtures/syntax-error.css000066400000000000000000000001621434221453000226200ustar00rootroot00000000000000@import "syntax-error.css"; syntax.error { /* Error isn't here, it's in the imported file */ color: green; } postcss-import-15.0.1/test/helpers/000077500000000000000000000000001434221453000172235ustar00rootroot00000000000000postcss-import-15.0.1/test/helpers/check-fixture.js000066400000000000000000000023441434221453000223250ustar00rootroot00000000000000"use strict" // builtin tooling const fs = require("fs") // external tooling const postcss = require("postcss") // plugin const atImport = require("../..") function read(name, ext) { ext = ext || ".css" return fs.readFileSync(`test/fixtures/${name}${ext}`, "utf8") } module.exports = function (t, file, opts, postcssOpts, warnings) { opts = { path: "test/fixtures/imports", ...opts } postcssOpts = { from: undefined, ...postcssOpts } if (typeof file === "string") file = { name: file, ext: ".css" } const { name, ext } = file return postcss(atImport(opts)) .process(read(name, ext), postcssOpts || {}) .then(result => { const actual = result.css const expected = read(`${name}.expected`) // handy thing: checkout actual in the *.actual.css file fs.writeFile(`test/fixtures/${name}.actual.css`, actual, err => { // eslint-disable-next-line no-console if (err) console.warn(`Warning: ${err}; not fatal, continuing`) }) t.is(actual, expected) if (!warnings) warnings = [] result.warnings().forEach((warning, index) => { t.is( warning.text, warnings[index], `unexpected warning: "${warning.text}"` ) }) }) } postcss-import-15.0.1/test/import-events.js000066400000000000000000000021711434221453000207340ustar00rootroot00000000000000"use strict" // builtin tooling const { readFileSync } = require("fs") const { resolve } = require("path") // external tooling const test = require("ava") const postcss = require("postcss") // plugin const atImport = require("..") test("should add dependency message for each import", t => { return postcss() .use(atImport({ path: "test/fixtures/imports" })) .process(readFileSync("test/fixtures/media-import.css"), { from: "test/fixtures/media-import.css", }) .then(result => { const deps = result.messages.filter( message => message.type === "dependency" ) const expected = [ { type: "dependency", plugin: "postcss-import", file: resolve("test/fixtures/imports/media-import-level-2.css"), parent: resolve("test/fixtures/media-import.css"), }, { type: "dependency", plugin: "postcss-import", file: resolve("test/fixtures/imports/media-import-level-3.css"), parent: resolve("test/fixtures/imports/media-import-level-2.css"), }, ] t.deepEqual(deps, expected) }) }) postcss-import-15.0.1/test/import.js000066400000000000000000000067011434221453000174350ustar00rootroot00000000000000"use strict" // builtin tooling const { readFileSync } = require("fs") const path = require("path") // external tooling const test = require("ava") const postcss = require("postcss") // plugin const atImport = require("..") // internal tooling const checkFixture = require("./helpers/check-fixture") test("should import stylsheets", checkFixture, "simple") test("should not import a stylsheet twice", checkFixture, "no-duplicate") test("should be able to import a stylsheet twice", checkFixture, "duplicates", { skipDuplicates: false, }) test("should import stylsheets with same content", checkFixture, "same") test("should ignore & adjust external import", checkFixture, "ignore") test("should not fail with only one absolute import", t => { const base = "@import url(http://)" return postcss() .use(atImport()) .process(base, { from: undefined }) .then(result => { t.is(result.warnings().length, 0) t.is(result.css, base) }) }) test("should not fail with absolute and local import", t => { return postcss() .use(atImport()) .process( "@import url('http://');\n@import 'test/fixtures/imports/foo.css';", { from: undefined } ) .then(result => t.is(result.css, "@import url('http://');\nfoo{}")) }) test("should keep @charset first", t => { const base = '@charset "UTF-8";\n@import url(http://);' return postcss() .use(atImport()) .process(base, { from: undefined }) .then(result => { t.is(result.warnings().length, 0) t.is(result.css, base) }) }) test( "should handle multiple @charset statements", checkFixture, "charset-import" ) test("should error if incompatable @charset statements", t => { t.plan(2) const file = "test/fixtures/charset-error.css" return postcss() .use(atImport()) .process(readFileSync(file), { from: file }) .catch(err => { t.truthy(err) t.regex( err.message, /Incompatable @charset statements:.+specified in.+specified in.+/s ) }) }) test("should error when file not found", t => { t.plan(1) const file = "test/fixtures/imports/import-missing.css" return postcss() .use(atImport()) .process(readFileSync(file), { from: file }) .catch(err => t.truthy(err)) }) test("should contain a correct sourcemap", t => { return postcss() .use(atImport()) .process(readFileSync("test/sourcemap/in.css"), { from: "test/sourcemap/in.css", to: null, map: { inline: false }, }) .then(result => { t.is( result.map.toString(), readFileSync( process.platform === "win32" ? "test/sourcemap/out.css.win.map" : "test/sourcemap/out.css.map", "utf8" ).trim() ) }) }) test("inlined @import should keep PostCSS AST references clean", t => { return postcss() .use(atImport()) .process("@import 'test/fixtures/imports/foo.css';\nbar{}", { from: undefined, }) .then(result => { result.root.nodes.forEach(node => { t.is(result.root, node.parent) }) }) }) test( "should work with empty files", checkFixture, "empty-and-useless", { path: "test/fixtures/imports" }, null, [`${path.resolve("test/fixtures/imports/empty.css")} is empty`] ) test("should work with no styles without throwing an error", t => { return postcss() .use(atImport()) .process("", { from: undefined }) .then(result => { t.is(result.warnings().length, 0) }) }) postcss-import-15.0.1/test/layer.js000066400000000000000000000042041434221453000172330ustar00rootroot00000000000000"use strict" // external tooling const test = require("ava") const postcss = require("postcss") const crypto = require("crypto") const cwd = process.cwd() // plugin const atImport = require("..") // internal tooling const checkFixture = require("./helpers/check-fixture") test("should resolve layers of import statements", checkFixture, "layer") test( "should correctly wrap imported at rules in layers", checkFixture, "layer-import-atrules", { nameLayer: hashLayerName, } ) test( "should correctly wrap imported at rules in anonymous layers", checkFixture, "layer-import-atrules-anonymous", { nameLayer: hashLayerName, } ) test("should group rules", checkFixture, "layer-rule-grouping", { nameLayer: hashLayerName, }) test("should pass the root file name to the nameLayer function", t => { return postcss() .use(atImport({ path: "test/fixtures/imports", nameLayer: hashLayerName })) .process('@import "foo.css" layer;', { from: "layer.css" }) .then(result => { t.is(result.css, `@layer import-anon-layer-52ff1597784c{\nfoo{}\n}`) }) }) test("should error when value is not a function", t => { return postcss() .use(atImport({ nameLayer: "not a function" })) .process("", { from: undefined }) .catch(error => t.is(error.message, "nameLayer option must be a function")) }) test("should throw when using anonymous layers without the nameLayer plugin option", t => { return postcss() .use(atImport({ path: "test/fixtures/imports" })) .process('@import "foo.css" layer;', { from: undefined }) .catch(err => { t.is( err.message, 'postcss-import: :1:1: When using anonymous layers in @import you must also set the "nameLayer" plugin option' ) }) }) function hashLayerName(index, rootFilename) { if (!rootFilename) { return `import-anon-layer-${index}` } // A stable, deterministic and unique layer name: // - layer index // - relative rootFilename to current working directory return `import-anon-layer-${crypto .createHash("sha256") .update(`${index}-${rootFilename.split(cwd)[1]}`) .digest("hex") .slice(0, 12)}` } postcss-import-15.0.1/test/lint.js000066400000000000000000000115651434221453000170750ustar00rootroot00000000000000"use strict" // external tooling const test = require("ava") const postcss = require("postcss") // plugin const atImport = require("..") const processor = postcss().use(atImport()) test("should warn when not @charset and not @import statement before", t => { return Promise.all([ processor.process(`a {} @import "";`, { from: undefined }), processor.process(`@media {} @import "";`, { from: undefined }), ]).then(results => { results.forEach(result => { const warnings = result.warnings() t.is(warnings.length, 1) t.is( warnings[0].text, "@import must precede all other statements (besides @charset or empty @layer)" ) }) }) }) test("should warn about all imports after some other CSS declaration", t => { return processor .process( ` a {} @import "a.css"; @import "b.css"; `, { from: undefined } ) .then(result => { t.plan(2) result.warnings().forEach(warning => { t.is( warning.text, "@import must precede all other statements (besides @charset or empty @layer)" ) }) }) }) test("should warn if non-empty @layer before @import", t => { return processor .process(`@layer { a {} } @import "a.css";`, { from: undefined }) .then(result => { t.plan(1) result.warnings().forEach(warning => { t.is( warning.text, "@import must precede all other statements (besides @charset or empty @layer)" ) }) }) }) test("should not warn if empty @layer before @import", t => { return processor .process(`@layer a; @import "";`, { from: undefined }) .then(result => { const warnings = result.warnings() t.is(warnings.length, 1) t.is(warnings[0].text, `Unable to find uri in '@import ""'`) }) }) test("should not warn if comments before @import", t => { return processor .process(`/* skipped comment */ @import "";`, { from: undefined }) .then(result => { const warnings = result.warnings() t.is(warnings.length, 1) t.is(warnings[0].text, `Unable to find uri in '@import ""'`) }) }) test("should warn if something before comments", t => { return processor .process(`a{} /* skipped comment */ @import "";`, { from: undefined }) .then(result => { t.is(result.warnings().length, 1) }) }) test("should not warn when @charset or @import statement before", t => { return Promise.all([ processor.process(`@import "bar.css"; @import "bar.css";`, { from: "test/fixtures/imports/foo.css", }), processor.process(`@charset "bar.css"; @import "bar.css";`, { from: "test/fixtures/imports/foo.css", }), ]).then(results => { results.forEach(result => { t.is(result.warnings().length, 0) }) }) }) test("should warn when @charset is not first", t => { return Promise.all([ processor.process(`a {} @charset "utf-8";`, { from: undefined }), processor.process(`@media {} @charset "utf-8";`, { from: undefined }), processor.process(`/* foo */ @charset "utf-8";`, { from: undefined }), processor.process(`@import "bar.css"; @charset "utf-8";`, { from: "test/fixtures/imports/foo.css", }), ]).then(results => { results.forEach(result => { const warnings = result.warnings() t.is(warnings.length, 1) t.is(warnings[0].text, "@charset must precede all other statements") }) }) }) test("should warn when a user didn't close an import with ;", t => { return processor .process(`@import url('http://') :root{}`, { from: undefined }) .then(result => { const warnings = result.warnings() t.is(warnings.length, 1) t.is( warnings[0].text, "It looks like you didn't end your @import statement correctly. " + "Child nodes are attached to it." ) }) }) test("should warn on invalid url", t => { return processor .process( ` @import foo-bar; @import ; @import ''; @import ""; @import url(); @import url(''); @import url(""); `, { from: undefined } ) .then(result => { const warnings = result.warnings() t.is(warnings.length, 7) t.is(warnings[0].text, `Unable to find uri in '@import foo-bar'`) t.is(warnings[1].text, `Unable to find uri in '@import '`) t.is(warnings[2].text, `Unable to find uri in '@import '''`) t.is(warnings[3].text, `Unable to find uri in '@import ""'`) t.is(warnings[4].text, `Unable to find uri in '@import url()'`) t.is(warnings[5].text, `Unable to find uri in '@import url('')'`) t.is(warnings[6].text, `Unable to find uri in '@import url("")'`) }) }) test("should not warn when a user closed an import with ;", t => { return processor .process(`@import url('http://');`, { from: undefined }) .then(result => { t.is(result.warnings().length, 0) }) }) postcss-import-15.0.1/test/media.js000066400000000000000000000010771434221453000172030ustar00rootroot00000000000000"use strict" // external tooling const test = require("ava") // internal tooling const checkFixture = require("./helpers/check-fixture") test( "should resolve media queries of import statements", checkFixture, "media-import" ) test("should resolve media queries", checkFixture, "media-query") test( "should resolve content inside import with media queries", checkFixture, "media-content" ) test( "should resolve media query imports with charset", checkFixture, "media-charset" ) test("should join correctly media queries", checkFixture, "media-join") postcss-import-15.0.1/test/node_modules/000077500000000000000000000000001434221453000202365ustar00rootroot00000000000000postcss-import-15.0.1/test/node_modules/auto/000077500000000000000000000000001434221453000212065ustar00rootroot00000000000000postcss-import-15.0.1/test/node_modules/auto/index.css000066400000000000000000000000101434221453000230160ustar00rootroot00000000000000.auto{} postcss-import-15.0.1/test/node_modules/by-hand/000077500000000000000000000000001434221453000215605ustar00rootroot00000000000000postcss-import-15.0.1/test/node_modules/by-hand/style.css000066400000000000000000000000121434221453000234230ustar00rootroot00000000000000.byHand{} postcss-import-15.0.1/test/node_modules/dep/000077500000000000000000000000001434221453000210065ustar00rootroot00000000000000postcss-import-15.0.1/test/node_modules/dep/index.css000066400000000000000000000000071434221453000226240ustar00rootroot00000000000000.dep{} postcss-import-15.0.1/test/node_modules/fake/000077500000000000000000000000001434221453000211445ustar00rootroot00000000000000postcss-import-15.0.1/test/node_modules/fake/main.css000066400000000000000000000000101434221453000225710ustar00rootroot00000000000000.fake{} postcss-import-15.0.1/test/node_modules/fake/package.json000066400000000000000000000000321434221453000234250ustar00rootroot00000000000000{ "style": "main.css" } postcss-import-15.0.1/test/node_modules/modularized-css/000077500000000000000000000000001434221453000233435ustar00rootroot00000000000000postcss-import-15.0.1/test/node_modules/modularized-css/foo/000077500000000000000000000000001434221453000241265ustar00rootroot00000000000000postcss-import-15.0.1/test/node_modules/modularized-css/foo/boo/000077500000000000000000000000001434221453000247055ustar00rootroot00000000000000postcss-import-15.0.1/test/node_modules/modularized-css/foo/boo/boomod.css000066400000000000000000000000221434221453000266700ustar00rootroot00000000000000.i-pity-the-boo{} postcss-import-15.0.1/test/node_modules/modularized-css/foo/index.css000066400000000000000000000000221434221453000257410ustar00rootroot00000000000000.i-pity-the-foo{} postcss-import-15.0.1/test/node_modules/nest/000077500000000000000000000000001434221453000212075ustar00rootroot00000000000000postcss-import-15.0.1/test/node_modules/nest/index.css000066400000000000000000000000161434221453000230250ustar00rootroot00000000000000@import "ed"; postcss-import-15.0.1/test/node_modules/nest/node_modules/000077500000000000000000000000001434221453000236645ustar00rootroot00000000000000postcss-import-15.0.1/test/node_modules/nest/node_modules/ed/000077500000000000000000000000001434221453000242545ustar00rootroot00000000000000postcss-import-15.0.1/test/node_modules/nest/node_modules/ed/index.css000066400000000000000000000000121434221453000260660ustar00rootroot00000000000000.nested{} postcss-import-15.0.1/test/node_modules/use-dep-too/000077500000000000000000000000001434221453000223775ustar00rootroot00000000000000postcss-import-15.0.1/test/node_modules/use-dep-too/index.css000066400000000000000000000000171434221453000242160ustar00rootroot00000000000000@import "dep"; postcss-import-15.0.1/test/node_modules/use-dep/000077500000000000000000000000001434221453000216005ustar00rootroot00000000000000postcss-import-15.0.1/test/node_modules/use-dep/index.css000066400000000000000000000000171434221453000234170ustar00rootroot00000000000000@import "dep"; postcss-import-15.0.1/test/order.js000066400000000000000000000012121434221453000172260ustar00rootroot00000000000000"use strict" // external tooling const test = require("ava") // internal tooling const checkFixture = require("./helpers/check-fixture") test(`should order nested imports correctly`, t => { let first = true const path = require("path") return checkFixture(t, "order", { path: "test/fixtures/imports", resolve: id => { return new Promise(res => { const doResolve = () => res(path.resolve("test/fixtures/imports", id)) if (first) { // Delay the first import so the second gets loaded first setTimeout(doResolve, 100) first = false } else doResolve() }) }, }) }) postcss-import-15.0.1/test/plugins.js000066400000000000000000000022731434221453000176040ustar00rootroot00000000000000"use strict" // external tooling const test = require("ava") const postcss = require("postcss") // plugin const atImport = require("..") // internal tooling const checkFixture = require("./helpers/check-fixture") test("should apply plugins to root", t => { const atRules = [] const rules = [] return checkFixture(t, "plugins", { plugins: [ css => { css.walk(node => { if (node.type === "rule") { rules.push(node.selector) if (node.selector === "bar") node.remove() else node.selector += "-converted" } if (node.type === "atrule") atRules.push(node.name) }) }, ], }).then(() => { t.deepEqual(atRules, ["import"]) t.deepEqual(rules, ["foo", "bar"]) }) }) test("should error when value is not an array", t => { return postcss() .use(atImport({ plugins: "foo" })) .process("", { from: undefined }) .catch(error => t.is(error.message, "plugins option must be an array")) }) test("should remain silent when value is an empty array", t => { return postcss() .use(atImport({ plugins: [] })) .process("", { from: undefined }) .then(result => t.is(result.css, "")) }) postcss-import-15.0.1/test/resolve.js000066400000000000000000000031131434221453000175740ustar00rootroot00000000000000"use strict" // external tooling const test = require("ava") // internal tooling const checkFixture = require("./helpers/check-fixture") test("should resolve relative to cwd", checkFixture, "resolve-cwd", { path: null, }) test(`should resolve relative to 'root' option`, checkFixture, "resolve-root", { root: "test/fixtures", path: null, }) test( `should resolve relative to postcss 'from' option`, checkFixture, "resolve-from", { path: null }, { from: "test/fixtures/file.css" } ) test( `should resolve relative to 'path' which resolved with cwd`, checkFixture, "resolve-path-cwd", { path: "test/fixtures/imports" } ) test( `should resolve relative to 'path' which resolved with 'root'`, checkFixture, "resolve-path-root", { root: "test/fixtures", path: "imports" } ) test("should resolve local modules", checkFixture, "resolve-local-modules", { path: null, }) test( "should resolve modules with path option", checkFixture, "resolve-path-modules", { path: "test/fixtures/imports/modules", } ) test( "should be able to consume npm package or local modules", checkFixture, "resolve-modules", { path: null }, { from: "test/fixtures/imports/foo.css" } ) test( "should be able to consume npm sub packages", checkFixture, "resolve-npm-subpackages", { path: null }, { from: "test/fixtures/imports/foo.css" } ) test( "should be able to consume modules from custom modules directories", checkFixture, "resolve-custom-modules", { path: null, addModulesDirectories: ["shared_modules"] }, { from: "test/fixtures/imports/foo.css" } ) postcss-import-15.0.1/test/shared_modules/000077500000000000000000000000001434221453000205575ustar00rootroot00000000000000postcss-import-15.0.1/test/shared_modules/shared-auto/000077500000000000000000000000001434221453000227735ustar00rootroot00000000000000postcss-import-15.0.1/test/shared_modules/shared-auto/index.css000066400000000000000000000000171434221453000246120ustar00rootroot00000000000000.shared-auto{} postcss-import-15.0.1/test/shared_modules/shared-by-hand/000077500000000000000000000000001434221453000233455ustar00rootroot00000000000000postcss-import-15.0.1/test/shared_modules/shared-by-hand/style.css000066400000000000000000000000211434221453000252100ustar00rootroot00000000000000.shared-byHand{} postcss-import-15.0.1/test/shared_modules/shared-dep/000077500000000000000000000000001434221453000225735ustar00rootroot00000000000000postcss-import-15.0.1/test/shared_modules/shared-dep/index.css000066400000000000000000000000161434221453000244110ustar00rootroot00000000000000.shared-dep{} postcss-import-15.0.1/test/shared_modules/shared-fake/000077500000000000000000000000001434221453000227315ustar00rootroot00000000000000postcss-import-15.0.1/test/shared_modules/shared-fake/main.css000066400000000000000000000000171434221453000243650ustar00rootroot00000000000000.shared-fake{} postcss-import-15.0.1/test/shared_modules/shared-fake/package.json000066400000000000000000000000321434221453000252120ustar00rootroot00000000000000{ "style": "main.css" } postcss-import-15.0.1/test/shared_modules/shared-nest/000077500000000000000000000000001434221453000227745ustar00rootroot00000000000000postcss-import-15.0.1/test/shared_modules/shared-nest/index.css000066400000000000000000000000251434221453000246120ustar00rootroot00000000000000@import "shared-ed"; postcss-import-15.0.1/test/shared_modules/shared-nest/shared_modules/000077500000000000000000000000001434221453000257725ustar00rootroot00000000000000postcss-import-15.0.1/test/shared_modules/shared-nest/shared_modules/shared-ed/000077500000000000000000000000001434221453000276265ustar00rootroot00000000000000postcss-import-15.0.1/test/shared_modules/shared-nest/shared_modules/shared-ed/index.css000066400000000000000000000000211434221453000314400ustar00rootroot00000000000000.shared-nested{} postcss-import-15.0.1/test/shared_modules/shared-use-dep-too/000077500000000000000000000000001434221453000241645ustar00rootroot00000000000000postcss-import-15.0.1/test/shared_modules/shared-use-dep-too/index.css000066400000000000000000000000261434221453000260030ustar00rootroot00000000000000@import "shared-dep"; postcss-import-15.0.1/test/shared_modules/shared-use-dep/000077500000000000000000000000001434221453000233655ustar00rootroot00000000000000postcss-import-15.0.1/test/shared_modules/shared-use-dep/index.css000066400000000000000000000000261434221453000252040ustar00rootroot00000000000000@import "shared-dep"; postcss-import-15.0.1/test/sourcemap/000077500000000000000000000000001434221453000175575ustar00rootroot00000000000000postcss-import-15.0.1/test/sourcemap/imported.css000077500000000000000000000000351434221453000221150ustar00rootroot00000000000000html { background: blue; } postcss-import-15.0.1/test/sourcemap/in.css000077500000000000000000000000601434221453000206760ustar00rootroot00000000000000@import "imported.css"; body { color: red; } postcss-import-15.0.1/test/sourcemap/index.html000077500000000000000000000001451434221453000215570ustar00rootroot00000000000000

Please view source & check sourcemap

postcss-import-15.0.1/test/sourcemap/out.css000077500000000000000000000001321434221453000210770ustar00rootroot00000000000000html { background: blue; } body { color: red; } /*# sourceMappingURL=out.css.map */ postcss-import-15.0.1/test/sourcemap/out.css.map000066400000000000000000000004431434221453000216550ustar00rootroot00000000000000{"version":3,"sources":["test/sourcemap/imported.css","test/sourcemap/in.css"],"names":[],"mappings":"AAAA;EACE,gBAAgB;AAClB;;ACAA;EACE,UAAU;AACZ","file":"test/sourcemap/in.css","sourcesContent":["html {\n background: blue;\n}\n","@import \"imported.css\";\n\nbody {\n color: red;\n}\n"]} postcss-import-15.0.1/test/sourcemap/out.css.win.map000066400000000000000000000004451434221453000224530ustar00rootroot00000000000000{"version":3,"sources":["test/sourcemap/imported.css","test/sourcemap/in.css"],"names":[],"mappings":"AAAA;EACE,gBAAgB;AAClB;;ACAA;EACE,UAAU;AACZ","file":"test\\sourcemap\\in.css","sourcesContent":["html {\n background: blue;\n}\n","@import \"imported.css\";\n\nbody {\n color: red;\n}\n"]} postcss-import-15.0.1/test/syntax-error.js000066400000000000000000000007411434221453000205760ustar00rootroot00000000000000"use strict" // builtin tooling const fs = require("fs") // external tooling const test = require("ava") const postcss = require("postcss") // plugin const atImport = require("..") test("SyntaxError in imported file throws", t => { return postcss(atImport({ path: "test/fixtures/imports" })) .process(fs.readFileSync("test/fixtures/syntax-error.css", "utf8"), { from: undefined, }) .then(() => t.fail("should error out")) .catch(err => t.truthy(err)) }) postcss-import-15.0.1/test/web_modules/000077500000000000000000000000001434221453000200665ustar00rootroot00000000000000postcss-import-15.0.1/test/web_modules/web-auto/000077500000000000000000000000001434221453000216115ustar00rootroot00000000000000postcss-import-15.0.1/test/web_modules/web-auto/index.css000066400000000000000000000000141434221453000234250ustar00rootroot00000000000000.web-auto{} postcss-import-15.0.1/test/web_modules/web-by-hand/000077500000000000000000000000001434221453000221635ustar00rootroot00000000000000postcss-import-15.0.1/test/web_modules/web-by-hand/style.css000066400000000000000000000000161434221453000240320ustar00rootroot00000000000000.web-byHand{} postcss-import-15.0.1/test/web_modules/web-dep/000077500000000000000000000000001434221453000214115ustar00rootroot00000000000000postcss-import-15.0.1/test/web_modules/web-dep/index.css000066400000000000000000000000131434221453000232240ustar00rootroot00000000000000.web-dep{} postcss-import-15.0.1/test/web_modules/web-fake/000077500000000000000000000000001434221453000215475ustar00rootroot00000000000000postcss-import-15.0.1/test/web_modules/web-fake/main.css000066400000000000000000000000141434221453000232000ustar00rootroot00000000000000.web-fake{} postcss-import-15.0.1/test/web_modules/web-fake/package.json000066400000000000000000000000321434221453000240300ustar00rootroot00000000000000{ "style": "main.css" } postcss-import-15.0.1/test/web_modules/web-nest/000077500000000000000000000000001434221453000216125ustar00rootroot00000000000000postcss-import-15.0.1/test/web_modules/web-nest/index.css000066400000000000000000000000221434221453000234250ustar00rootroot00000000000000@import "web-ed"; postcss-import-15.0.1/test/web_modules/web-nest/web_modules/000077500000000000000000000000001434221453000241175ustar00rootroot00000000000000postcss-import-15.0.1/test/web_modules/web-nest/web_modules/web-ed/000077500000000000000000000000001434221453000252625ustar00rootroot00000000000000postcss-import-15.0.1/test/web_modules/web-nest/web_modules/web-ed/index.css000066400000000000000000000000161434221453000271000ustar00rootroot00000000000000.web-nested{} postcss-import-15.0.1/test/web_modules/web-use-dep-too/000077500000000000000000000000001434221453000230025ustar00rootroot00000000000000postcss-import-15.0.1/test/web_modules/web-use-dep-too/index.css000066400000000000000000000000231434221453000246160ustar00rootroot00000000000000@import "web-dep"; postcss-import-15.0.1/test/web_modules/web-use-dep/000077500000000000000000000000001434221453000222035ustar00rootroot00000000000000postcss-import-15.0.1/test/web_modules/web-use-dep/index.css000066400000000000000000000000231434221453000240170ustar00rootroot00000000000000@import "web-dep";