Giter VIP home page Giter VIP logo

vit's Introduction

English | 简体中文

Vit logo

GitHub stars npm package node compatility vite compatility

Vit 🚀

React application framework inspired by UmiJS.

  • ⚡️ Manually Defined Routing
  • ✨ Routing-based Code Splitting
  • 🎁 Exported Pure Static Application
  • 🎨 Mock Data, Usable in the Production

Routing

The framework takes over route definition and rendering, application entry. Developers only focus on business development after configure the route definition.

Mock Data

Based on vite-plugin-mock, Built-in interception for fetch, you can easily use mock data in the production environment to facilitate project preview.

How to use?

Install

# Vite plugin, Core function realization
$ yarn add @vitjs/vit --dev

# Vit app runtime, provide application runtime related components
$ yarn add @vitjs/runtime

Config

<!-- index.html -->
<body>
  <div id="root"></div>
  <script type="module" src="/@vit-app"></script>
</body>
// vite.config.ts
import type { UserConfig } from 'vite';
import vitApp from '@vitjs/vit';

const config: UserConfig = {
  plugins: [
    vitApp({
      // Configure routing according to the project structure, and import components uniformly from the `src` directory
      // icon currently supports automatic escaping as icons in [`@ant-design/icons`](https://ant.design/components/icon/#List-of-icons)
      routes: [
        {
          path: '/',
          component: './layouts/BasicLayout',
          routes: [
            {
              path: '/',
              redirect: '/welcome',
              exact: true,
            },
            {
              path: '/welcome',
              icon: 'smile',
              name: 'Welcome',
              component: './pages/Welcome',
            },
          ],
        },
      ],
    }),
  ],
};

export default config;
// tsconfig.json
// For better TS type prompt, you need to add the following configuration
{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "@@/*": ["./src/.vit/*"]
    }
  }
}

In addition, the plugin will generate runtime dependencies, so the build script of the application needs to remove the tsc command. In the end, add the directory .vit where the temporary files are located to .gitignore.

Auto import

globalImports lets you customize the files that need to be imported globally automatically. By default, you can see import.ts

In particular, _app.tsx can be automatically import to rewrite the application's rendering logic.

Upgrade

$ yarn upgrade --scope @vitjs

$ yarn upgrade --scope @vitjs --latest

Application Template

For more details, please refer directly to the application template yunsii/vite-react. It is worth noting that the current plugin is still under heavy development, API and usages are not set in stone yet.

vit's People

Contributors

scrum avatar yunsii avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

vit's Issues

请教下你咋解决这个错误得 error TS7016: Could not find a declaration file for module 'react-color'.

yarn run v1.22.17
$ tsc && vite build
node_modules/@ant-design/pro-form/lib/components/ColorPicker/index.d.ts:2:40 - error TS7016: Could not find a declaration file for module 'react-color'. 'C:/Users/pwt/src/vitereacttest/node_modules/react-color/lib/index.js' implicitly has an 'any' type.
Try npm i --save-dev @types/react-color if it exists or add a new declaration (.d.ts) file containing declare module 'react-color';

2 import type { SketchPickerProps } from 'react-color';
~~~~~~~~~~~~~

node_modules/@ant-design/pro-utils/lib/types/index.d.ts:4:40 - error TS7016: Could not find a declaration file for module 'react-color'. 'C:/Users/pwt/src/vitereacttest/node_modules/react-color/lib/index.js' implicitly has an 'any' type.
Try npm i --save-dev @types/react-color if it exists or add a new declaration (.d.ts) file containing declare module 'react-color';

4 import type { SketchPickerProps } from 'react-color';
~~~~~~~~~~~~~

Found 2 errors in 2 files.

Errors Files
1 node_modules/@ant-design/pro-form/lib/components/ColorPicker/index.d.ts:2
1 node_modules/@ant-design/pro-utils/lib/types/index.d.ts:4
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

is vit support vite's `resolve.alias` ?

the code below seems not working :

// vite.config.ts
export default defineConfig({
  vitApp({
    // vit configs ...
  }),
  // some other vite configs ...
  resolve: {
    alias: {
      "~/": path.resolve(__dirname, "./"),
      "~": path.resolve(__dirname, "./node_modules/"),
      "@/": path.resolve(__dirname, "/src/"),
      "~@/": path.resolve(__dirname, "/src/"),
      "lodash": 'lodash-es',
      "~antd": path.resolve(__dirname, "./node_modules/antd/"),
    },
  },
})

Having an issue with a basic react app

Hello, I tried to reproduce the example at yunsii/vite-react

I end up with these errors and a blank page 😢

CleanShot 2022-07-08 at 22 55 28

My _app.tsx, vite.config.ts and routes.ts are the exact same as shown in yunsii/vite-react

想请教动态路由怎麽设定

前辈们好,目前在实作使用到像这样的动态路由

{ path: '/process-pending/:id/detail', icon: 'FileSearch', name: '查询明细', component: './pages/ProcessPending/Detail/index.jsx', hideInMenu: true },

使用开发模式 vite 可正常执行,但执行 vite build 打包却会出现路径不合法的错误

error during build: Error: Illegal characters in path. at pathArg (C:\Users\BLKsherry\Desktop\Project\frontend\node_modules\mkdirp\lib\path-arg.js:20:27) at Function.mkdirpSync [as sync] (C:\Users\BLKsherry\Desktop\Project\frontend\node_modules\mkdirp\index.js:18:10) at Service.writeFile (C:\Users\BLKsherry\Desktop\Project\frontend\node_modules\@vitjs\core\dist\Service\index.js:49:26) at C:\Users\Sherry.Bing\Desktop\Project\Bothwell\bothwell\frontend\node_modules\@vitjs\vit\dist\preset\exportStatic.js:23:17 at Array.map (<anonymous>) at exportStatic (C:\Users\BLKsherry\Desktop\Project\frontend\node_modules\@vitjs\vit\dist\preset\exportStatic.js:18:12) at Object.closeBundle (C:\Users\BLKsherry\Desktop\Project\frontend\node_modules\@vitjs\vit\dist\vitApp.js:37:39) at file:///C:/Users/BLKsherry/Desktop/Project/frontend/node_modules/rollup/dist/es/shared/rollup.js:22748:40 at processTicksAndRejections (node:internal/process/task_queues:96:5) at async Promise.all (index 0) at async PluginDriver.hookParallel (file:///C:/Users/BLKsherry/Desktop/Project/frontend/node_modules/rollup/dist/es/shared/rollup.js:22676:9) at async Object.close (file:///C:/Users/BLKsherry/Desktop/Project/frontend/node_modules/rollup/dist/es/shared/rollup.js:23750:13) at async Promise.all (index 0) at async build (file:///C:/Users/BLKsherry/Desktop/Project/frontend/node_modules/vite/dist/node/chunks/dep-c842e491.js:46421:13) at async CAC.<anonymous> (file:///C:/Users/BLKsherry/Desktop/Project/frontend/node_modules/vite/dist/node/cli.js:756:9)

想请问应该怎麽设置呢?谢谢!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.