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

sute

v1.2.3

Published

- 简单,方便,快捷的配置webpack

Downloads

4

Readme

说明文档

sute: 一个基于webapck管理react应用程序的工具.

特点:

  • 简单,方便,快捷的配置webpack

  • 支持通过swc和esbuild 加速打包.

  • 内置支持TypeScript

环境要求

  • Node.js 版本Node.js 16+

安装:

npm install sute --save-dev
# or
yarn add sute --dev
# or 
pnpm add sute --save-dev

命令行

sute  init

  • 初始化配置, 生成一个sute.config.js文件.

  • 自动生成entry,output等默认配置

"use strict";
const path = require("path");
const appDir = process.cwd();
const resolveApp = (dir) => path.resolve(appDir, dir);


const ConfigFile = {
  entry: {
    index: resolveApp("src/index.tsx")//默认resolve.extensions自动匹配src文件
  },
  output: {
    filename: "static/js/[name]_[[hash:8].js",
    path: resolveApp("./build"),
    clean: true
  },
  htmlWebpackPlugin: {
    title: "sute_cli",
    template: resolveApp("./public/index.html")
  },
  definePlugin: {
    BASE_URL: '"./"'
  },
  copyWebpackPlugin: {
    patterns: [
      {
        from: resolveApp("./public"),
        globOptions: {
          ignore: [
            "**/index.html"
          ]
        }
      }
    ]
  },
  serve: {
    port: 3000,
    host: "127.0.0.1",
    hot: true,
  },
};
module.exports = ConfigFile;
说明

resolve 默认配置

  • extensions:[".wasm", ".mjs", ".js", ".jsx", ".ts", ".tsx", ".vue", ".json"]

  • alias: 根据 src 下子目录自动生成,您无需匹配

    {
     '@': resolveApp("./src"),
     pages: resolveApp("./src/pages"),  
     router: resolveApp("./src/router"),  
     services: resolveApp("./src/services"),
     ...
    }

sute dev

启动开发服务器

sute build

使用内部webpack实例打包文件

配置

配置项

  //  常用plugins 便捷化入口.
  htmlWebpackPlugin?: HtmlWebpackPlugin.Options,
  copyWebpackPlugin?: CopyPlugin.PluginOptions,
  definePlugin?: DefinePlugin.Options配置
  // 自定义
  miniCssExtractPlugin?: boolean, // 是否将css提取到一个独立的css文件中.
  threadLoader?: boolean | threadLoader.options  // 是否开启多线程打包, boolean 类型和对象类型
  buildFileAnaly?: boolean//打包后的文件分析
  buildTimeAnaly?: boolean//打包后的时间分析
  httpCompressiton?: boolean | compressionWebpackPlugin.options //  是否http 压缩
  buildSpeendUp?: boolean | buildSpeendUpType, // 开启esbuild 和swc 加速
  esbuildMinimizer?: boolean // 启用esbuild 压缩处理器,
  deploy?: autoUploadPluginType | autoUploadPluginType[], // 打包后自动部署~
  serve?: IserviceConfig | compilerType,// 开发环境相关依赖

说明

buildSpeendUp
  • 默认值为 false,
  • buildSpeendUp:true 启动 esbuild 加速.
  • buildSpeendUp 为对象时,可传type 和其对应的options
export type buildSpeendUpType = {
  type: "swc" | "esbuild",
  options: objType
}
  • type:"esbuild" 启动esbuild-loader 替代babel
  • options 为对应的esbuild-loader 对应参数

type:esbuild 时options默认值

{
      // JavaScript version to compile to
      loader: "tsx",
      target: 'es2015',
}
  • type:"swc" 启动swc-loader 替代babel.
  • options 为对应的swc-loader 对应参数

type:"swc" 时options默认值

{
      jsc: {
        parser: {
          syntax: "typescript",
          tsx: true,
          decorators: true,
        },
        transform: {
          legacyDecorator: true,
        },
        externalHelpers: true, // 注意这里设置true时,需要在项目下安装@swc/helpers
        target: 'es5',
      },
      env: {
        targets: "last 3 major versions, > 0.1%", // 根据项目设置
        mode: "usage",
        coreJs: "3" // 根据项目选择
      },
      isModule: 'unknown'
}
deploy
  • 打包build时自动部署(传入单个对象或对象数组)

取参

export type autoUploadPluginType = {
  buildPath?: string, // 不传为默认打包地址.build下
  host: string,
  username: string,
  password: string,
  remotePath: string
}
serve

proxy 传参

{
  '/api':{
    target: 'http://test1.com/',
    changeOrigin: true,
  },
  '/api2': {
    target: 'http://test2.com/',
    changeOrigin: true,
  },
}

其余 port host hot 等传参和webpack-dev-serve 传参一致.