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

@kkt/plugin-pro-config

v1.1.5

Published

kktp plugins

Downloads

29

Readme

配置 .kktprc

kktp内置配置处理包,配置约定在根目录,命名为 .kktprc.[ts|js]

参数

import webpack from 'webpack';
import { LoaderConfOptions, WebpackConfiguration } from 'kkt';
import { RouterPluginProps } from '@kkt/plugin-pro-router';
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';

export type DefaultDefineType = {};

export type OverrideWebpackType = (
  conf: WebpackConfiguration,
  env: 'development' | 'production',
  options?: LoaderConfOptions | undefined,
) => WebpackConfiguration;

export type PluginsType = (
  | ((this: webpack.Compiler, compiler: webpack.Compiler) => void)
  | webpack.WebpackPluginInstance
  | [string, Record<string, any>]
  | string
)[];

export type KKTPlugins = (
  | OverrideWebpackType
  | {
      loader?: OverrideWebpackType;
      options?: LoaderConfOptions | undefined | Record<string, any>;
    }
  | string
  | [string, Record<string, any>]
)[];

export type KKTPAnalyze = BundleAnalyzerPlugin['opts'];

export interface OverrideKKTPConfigProps extends Omit<WebpackConfiguration, 'plugins'> {
  /**
   * 别名
   * 默认系统内置两个别名
   * 1. `@` 指向 src 目录
   * 2. `@@` 指向 src/.kktp 目录
   */
  alias?: Record<string, string | false | string[]>;
  /** 插件 */
  plugins?: PluginsType;
  /** 默认全局变量 define , 注意:对象的属性值会经过一次 JSON.stringify 转换   */
  define?: Record<string, any> & DefaultDefineType;
  /** kkt plugin  */
  kktPlugins?: KKTPlugins;
  /** 项目前缀 */
  publicPath?: string;
  /** 提供回调函数,更改 webpack 的最终配置。 */
  overrideWebpack?: OverrideWebpackType;
  /** 输出 */
  output?: Omit<WebpackConfiguration['output'], 'publicPath'>;
  /**自动生成文件目录名称**/
  cacheDirName?: string;
  /**自动生成入口文件*/
  initEntery?: boolean;
  /**路由配置*/
  initRoutes?: RouterPluginProps | boolean;
  /**
   * 1. 自动生成models集合配置文件
   * 2. 当传递的是字符串的时候,用于自己定义状态管理的引用地址
   */
  initModel?: boolean | string;
  /** 是否开启权限 */
  access?: boolean;
  /** 分析产物构成 */
  analyze?: KKTPAnalyze;
}

配置文件

// .kktprc.ts
export default {
  // ...
  alias:{
    "react-native":"react-native-web",
  },
  define:{
    "BAST":"111",
    "TEST":"222"
  }
  initEntery:true,
  initRoutes:true,
}

plugins使用

// .kktprc.ts
export default {
  // ...
  plugins:["@kkt/plugin-pro-router"]
  // plugins:[["@kkt/plugin-pro-router",{ autoRoutes:true, }]]  
}

analyze 使用

用于分析 bundle 构成。通过配置--analyzer=1生效。可以通过analyze选项自定义配置。analyze 插件的具体配置项,见 webpack-bundle-analyzer

// package.json
"scripts": {
  "start": "kktp start --analyzer=1",
  "build": "kktp build --analyzer=1"
},

// .kktprc.ts
export default {
  // ...
  analyzer: {
    analyzerPort: 9999 // 自定义端口
  }
}

overrideWebpack 使用

// .kktprc.ts
export default {
  // ...
  overrideWebpack:(conf, env, options)=>{
    // 处理 conf
    return conf;
  }
}

Contributors

License

Licensed under the MIT License.