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

umi-plugin-antd-theme-fork

v2.1.5

Published

<!-- @format -->

Downloads

4

Readme

修复umi-plugin-antd-theme 插件 umi api找不到问题,让其在[email protected]版本中正常工作

umi-plugin-antd-theme的fork版本

NPM version NPM downloads

Usage

1.优先读取config/theme.config.js配置

config/theme.config.js方式可以动态加载模块,方便一些动态处理

Configure in config/theme.config.js,

const fs = require('fs');
const Path = require('path');
const NativeModule = require('module');
const vm = require('vm');

const getModuleFromString = (bundle, filename) => {
  const m = { exports: {} };
  const wrapper = NativeModule.wrap(bundle);
  const script = new vm.Script(wrapper, {
    filename,
    displayErrors: true,
  });
  const result = script.runInThisContext(); 
  result.call(m.exports, m.exports, require, m); 
  return m;
};

module.exports = function genThemeConfig() {
  const darkString = fs.readFileSync(
    Path.join(process.cwd(), './src/themes/dark/index.js'),
    'utf-8'
  ); 

  const dark = getModuleFromString(darkString, 'bundle.js');

  return {
    theme: [
      // { key: '官方暗黑', fileName: 'dark.css', theme: 'dark', className: 'theme-dark' },
      {
        key: '暗黑主题',
        fileName: 'custom-dark.css',
        className: 'theme-custom-dark',
        modifyVars: dark.exports,
      },
    ],
    // 是否压缩css
    min: true,
    // css module
    isModule: true,
    // 忽略 antd 的依赖
    ignoreAntd: false,
    // 忽略 pro-layout
    ignoreProLayout: false,
    // 不使用缓存
    cache: true,
  };
};

2.没有第一步的配置就读取plugin option,参数如下,最后读取config/theme.config.json

plugin option的配置会被缓存,无法热更新,所以不推荐,推荐config/theme.config.jsconfig/theme.config.json方式 config/theme.config.json方式就是静态文件,需要转换文件格式,有点麻烦

Configure in plugin option or config/theme.config.json,

{
  "theme": [
    {
      "theme": "dark",
      "fileName": "dark.css"
    },
    {
      "fileName": "mingQing.css",
      "modifyVars": {
        "@primary-color": "#13C2C2"
      }
    }
  ],
  // 是否压缩css
  "min": true,
  // css module
  "isModule": true,
  // 忽略 antd 的依赖
  "ignoreAntd": false,
  // 忽略 pro-layout
  "ignoreProLayout": false,
  // 不使用缓存
  "cache": true
}

you can get config in window.umi_plugin_ant_themeVar

LICENSE

MIT