npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@render-ae86/ae86-component-build-plugin

v2.5.0

Published

基于ae86-webpack-builder封装的编译react组件的build-plugin

Downloads

3

Readme

ae86-component-build-plugin

Ae86 Component 使用的基础编译插件

介绍

基于ae86-webpack-builder封装的编译 react 组件的 build-plugin

用法

在根目录的中配置文件中(这里以 build.js 为例)添加如下代码即可:

export default {
  plugins: ["@render-ae86/ae86-component-build-plugin", options],
};

插件配置(options)

ae86-component-build-plugin 配置如下: | 选项 | 作用 | 类型 | 默认值 | | --- | --- | --- | --- | | metas | 在 HTML 文档的 head 节点中插入自定义代码,例如: | Array<string> | [''] | | scripts | 在 HTML 文档的 body 节点中插入自定义代码,例如:console.log(1) | Array<string> | [''] | | ConfigOptions | 配置详情请查看@render-ae86/ae86-app-base-webpack-config | | |

注意使用 ConfigOptions 的时候,不需要额外的属性定义。 正确的配置如下:

export default {
  plugins: [
    "@render-ae86/ae86-component-build-plugin",
    {
      // 比如配置处理样式的各种loader属性和cssInline
      cssInline: true,
      cssOptions: {
        // your config
      },
    },
  ],
};

错误的配置:

export default {
  plugins: [
    "@render-ae86/ae86-component-build-plugin",
    {
      // 这个是错误的
      ConfigOptions: {
        // 比如配置处理样式的各种loader属性和cssInline
        cssInline: true,
        cssOptions: {
          // your config
        },
      },
    },
  ],
};

功能介绍

ae86-component-build-plugin 提供了非常多开箱即用的功能,具体如下:

  1. 插件内部提供 html 和 react 入口文件,减轻开发者的配置,专注于组件的开发即可。
  2. 提供移动端和 pc 端的适配能力,针对样式中使用 rpx 作为 css 属性单位的情况,自动进行向 vm 单位的转化,开发者无需进行额外的适配工作。需要注意的是,插件内部转化的尺寸是按照 IPhone 6 来设计的,即基数为 750,1rpx = 0.5px = 1 物理像素。
  3. 支持 css、和 css 预处理语法(less、scss、sass)和 css modules。
  4. 使用插件构建出资源的目录为 dist,该目录下存放着 umd 规范下的 react 组件和对应的 ts 类型文件,以及对应的 css 文件。
  5. 插件还会输出两个目录为 es 和 lib,分别对应 esm 和 cjs 规范下的 react 组件。

插件实现原理

为了使得开发者更加熟练使用该插件,简单介绍下插件的实现原理:

  1. 使用@render-ae86/ae86-app-base-webpack-config得到基础 webpack 配置,然后根据得到的配置做了定制化的修改
  2. 编写基于ae86-webpack-builder的插件类,享用到 ae86-webpack-builder 带来的编译能力和其他 API 方法。

更多细节欢迎阅读ae86-component-build-plugin的源码。