added vite support

This commit is contained in:
srgooglo 2022-01-03 18:36:20 +01:00
parent efd93156b1
commit 50f1df1d7e
4 changed files with 48 additions and 18 deletions

View File

@ -1,33 +1,31 @@
const path = require('path')
const aliases = {
"@antd": path.resolve(__dirname, "../../node_modules/antd"),
"@": path.resolve(__dirname, 'src'),
'~/': `${path.resolve(__dirname, 'src')}/`,
"__": __dirname,
"@src": path.resolve(__dirname, 'src'),
schemas: path.resolve(__dirname, 'constants'),
controllers: path.resolve(__dirname, 'src/controllers'),
config: path.join(__dirname, 'config'),
extensions: path.resolve(__dirname, 'src/extensions'),
pages: path.join(__dirname, 'src/pages'),
theme: path.join(__dirname, 'src/theme'),
locales: path.join(__dirname, 'src/locales'),
core: path.join(__dirname, 'src/core'),
"@pages": path.join(__dirname, 'src/pages'),
components: path.join(__dirname, 'src/components'),
models: path.join(__dirname, 'src/models'),
}
module.exports = (config) => {
if (typeof config.windowContext.process === 'undefined') {
config.windowContext.process = Object()
module.exports = (config = {}) => {
if (!config.resolve) {
config.resolve = {}
}
if (!config.server) {
config.server = {}
}
config.windowContext.process = config.windowContext.__evite
config.windowContext.process["versions"] = process.versions
config.resolve.alias = {
...config.resolve.alias,
...aliases,
}
config.aliases = {
...config.resolve.alias,
...aliases,
config.resolve.alias = aliases
config.server.port = 8000
config.server.host = "0.0.0.0"
config.server.fs = {
allow: [".."]
}
config.css = {

12
packages/app/index.html Normal file
View File

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.ico" />
<meta name="viewport" content="viewport-fit=cover, width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/vite.entry.jsx"></script>
</body>
</html>

View File

@ -0,0 +1,5 @@
import React from "react"
import ReactDOM from "react-dom"
import App from "./App"
ReactDOM.render(<App />, document.getElementById("root"))

View File

@ -0,0 +1,15 @@
import { defineConfig } from 'vite'
import getConfig from "./.config.js"
import Pages from 'vite-plugin-pages'
import reactRefresh from '@vitejs/plugin-react-refresh'
export default defineConfig({
plugins: [
reactRefresh(),
Pages({
react: true,
extensions: ['jsx', 'tsx'],
}),
],
...getConfig(),
})