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

@sweet-milktea/milktea-vite

v4.2.0

Published

vite配置函数

Downloads

61

Readme

@sweet-milktea/milktea-vite

使用

如何使用

  1. 在工程目录下创建.sweetrc.jssweet.config.mjs文件,然后通过cli工具运行。(支持typescript,即.sweetrc.tssweet.config.ts文件)

  2. 在node内运行函数。

import {
  config as viteConfig, // vite开发环境配置
  build as viteBuild,   // vite生产环境配置
  serverRenderBuild     // vite SSR生产环境配置
} from '@sweet-milktea/milktea-vite';

// sweetConfig { SweetConfig | string | null | undefined }: 覆盖文件,优先级最高
// mode { string }: 开发模式 development,生产模式 production
const vite = await viteConfig({
  // 配置项
  sweetConfig: null,
  mode: 'development'
});

配置文件.sweetrc.js说明

使用方法

根目录下创建.sweetrc.js文件。代码如下所示:

module.exports = {
  ... // 配置
};

module.exports = function(info) {
  return {
    ... // 配置
  };
};

配置项

  • mode { string } : 开发模式还是生产模式
  • frame { string } : 值为reactvue,是否为react或vue模式,并自动修改默认配置,添加plugin
  • vite { object } : vite配置,会合并到默认配置中
  • chainVite { Function } : 通过扩展或修改vite配置
  • typescript(ts) { object } : typescript配置
    • configFile { string } : typescript的配置文件
    • tsChecker { boolean } : 设置为false时,关闭vite-plugin-checker插件注入

下面的配置是关于服务器端渲染的

  • severEntry { any } : 服务器端的文件入口(参考vite的SSR)

关于vue

如果使用vue,需要手动安装@vitejs/plugin-vue@vitejs/plugin-vue-jsx@vue/compiler-sfc(vue3)。

关于typescript

使用typescript,需要手动安装typescript

info

info是当前环境的信息。

  • info.environment:当前环境,可能的值为clientserver。分别为编译dll文件、编译浏览器端代码、编译node端代码。

api、服务器端渲染

使用typescript

在项目内添加tsconfig.json文件。