@dr.pogodin/postcss-modules-resolve-imports

中文文档
1.4.7发布于 2023/04/09MITCommonJS近 30 天下载 1.1万

Resolves ICSS imports

此软件包已被标记为弃用

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

原始使用文档
文档目录3 节
  1. Options
  2. Reference Guides
  3. License

PostCSS Modules: Resolve Imports

Latest NPM Release NPM Monthly Downloads CircleCI GitHub Repo stars

Transforms:

:import("library/button.css") {
  i__imported_button_0: button;
}
:export {
  continueButton: _source_continueButton i__imported_button_0;
}
._source_continueButton {
  color: green;
}

into:

:export {
  continueButton: _source_continueButton _button_button
}
._button_button {
  /*common button styles*/
}
._source_continueButton {
  color: green
}

Note: should be used after postcss-modules-extract-imports and postcss-modules-scope.

The postcss-modules-resolve-imports plugin also fixes @import and url() paths (which doesn't start from /) for the included modules from the different folders.

Sponsor


This is also a fork of postcss-modules-resolve-imports, upgraded to use latest versions of dependencies. Released to NPM as a new package @dr.pogodin/postcss-modules-resolve-imports


Options

icssExports boolean

Adds the :export declaration to the resulting css. In case you need the JavaScript object with tokens, you may obtain it by accessing the lazyResult.root.exports property. For example,

const lazyResult = postcss([...plugins]).process(cssString, {from: filepath});
const tokens = lazyResult.root.exports;

resolve object

Configure how modules should be resolved.

resolve.alias object

Create an aliases for the modules paths. For example, create an alias for the lib directory with common modules:

alias: {
  lib: path.resolve(__dirname, 'lib'),
},

Now, instead of using relative paths when composing:

.button {
  composes: normal from '../../lib/button.css';
}

you can use the alias:

.button {
  composes: normal from 'lib/button.css';
}

resolve.extensions array

Automaticaly check files with the provided extensions.

['.css']

Allows you to omit file extensions while using compose:

.button {
  composes: normal from '../lib/button';
}

resolve.modules array

Provide additional directories to check the modules in. Should be absolute paths only.

[path.resolve(__dirname, 'lib')]

resolve.mainFile string

Specifies the default filename to be used while resolving directories. Default: index.css.

resolve.preserveSymlinks boolean

Wether to resolve symlinks in paths. Defaults to nodejs behaviour: false, (parsed from --preserve-symlinks or environment variable PRESERVE_SYMLINKS).

Reference Guides

License

The MIT License

版本与发布记录

@dr.pogodin/postcss-modules-resolve-imports 共发布 8 个版本,首次发布于 2020/09/25;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.4.7latest2023/04/093 年前
1.4.62022/11/114 年前
1.4.52022/06/074 年前
1.4.42022/02/234 年前
1.4.32021/04/095 年前
1.4.22020/09/296 年前

关于 @dr.pogodin/postcss-modules-resolve-imports 的常见问题

@dr.pogodin/postcss-modules-resolve-imports 是什么?

Resolves ICSS imports注意:该包已被作者标记为弃用——Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

如何安装 @dr.pogodin/postcss-modules-resolve-imports?

在项目目录运行 npm install @dr.pogodin/postcss-modules-resolve-imports,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:postcss(^8)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@dr.pogodin/postcss-modules-resolve-imports 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/dr.pogodin__postcss-modules-resolve-imports 是否存在。

@dr.pogodin/postcss-modules-resolve-imports 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@dr.pogodin/postcss-modules-resolve-imports 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >= 14。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@dr.pogodin/postcss-modules-resolve-imports 可以商用吗?

@dr.pogodin/postcss-modules-resolve-imports 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@dr.pogodin/postcss-modules-resolve-imports 的下载量有多少?

根据 npm 官方下载统计,@dr.pogodin/postcss-modules-resolve-imports 在 2026/10/13 – 2026/11/11 这 30 天内被下载 11,307 次,日均约 377 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@dr.pogodin/postcss-modules-resolve-imports 还在维护吗?

最新版本 1.4.7 发布于 2023/04/09(3 年前);至今共发布 8 个版本,其中过去 12 个月发布了 0 个;首次发布于 2020/09/25。作者已将其标记为弃用,新项目建议寻找替代方案。