#swc-plugin #emotion #com #next #label #babel-plugin-transform-imports #css-in-js

swc_plugin_emotion

SWC 插件用于 https://npmjs.net.cn/package/babel-plugin-transform-imports

17 个版本 (破坏性更新)

0.12.4 2022年11月10日
0.12.1 2022年10月20日
0.0.0 2021年7月5日

#2 in #emotion

Download history 4/week @ 2024-03-20 161/week @ 2024-03-27 3/week @ 2024-04-03

每月下载量 60

Apache-2.0

6KB
73

emotion

emotion css-in-js 库的官方插件。

配置

该插件使用与 Next emotion 文档中描述相同的配置。

{
  jsc: {
    ...
   experimental: {
     plugins: [ ['@swc/plugin-emotion', {
      // default is true. It will be disabled when build type is production.
      sourceMap?: boolean,
      // default is 'dev-only'.
      autoLabel?: 'never' | 'dev-only' | 'always',
      // default is '[local]'.
      // Allowed values: `[local]` `[filename]` and `[dirname]`
      // This option only works when autoLabel is set to 'dev-only' or 'always'.
      // It allows you to define the format of the resulting label.
      // The format is defined via string where variable parts are enclosed in square brackets [].
      // For example labelFormat: "my-classname--[local]", where [local] will be replaced with the name of the variable the result is assigned to.
      labelFormat?: string,
    }] ]
   }
}

致谢

插件本身的源代码(非转换)是从 https://github.com/IvanRodriCalleja/emotion-swc-plugin 复制的

依赖项

~8–16MB
~234K SLoC