[📲] Switched to vite

This commit is contained in:
ThinLiquid 2023-10-16 22:35:32 +01:00
parent 126c2ae23b
commit 9bef5247f3
8 changed files with 3921 additions and 473 deletions

4329
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -5,9 +5,8 @@
"main": "src/index.ts",
"scripts": {
"test": "ts-standard",
"build": "webpack",
"watch": "webpack --watch",
"serve": "webpack serve"
"build": "vite build",
"serve": "vite serve"
},
"keywords": [],
"author": "",
@ -20,16 +19,18 @@
"babel-loader": "^9.1.3",
"css-loader": "^6.8.1",
"file-loader": "^6.2.0",
"html-webpack-plugin": "^5.5.3",
"less": "^4.2.0",
"less-loader": "^11.1.3",
"node-polyfill-webpack-plugin": "^2.0.1",
"parcel": "^2.10.0",
"source-map-loader": "^4.0.1",
"style-loader": "^3.3.3",
"ts-standard": "^12.0.2",
"typescript": "^5.2.2",
"webpack": "^5.88.2",
"webpack-cli": "^5.1.4",
"vite-plugin-html": "^3.2.0",
"vite-plugin-node-polyfills": "^0.15.0",
"vite-plugin-require": "^1.1.11",
"vite-require": "^0.2.3",
"webpack-dev-server": "^4.15.1"
},
"dependencies": {
@ -38,6 +39,7 @@
"filer": "^1.4.1",
"prism-code-editor": "^1.2.2",
"prismjs": "^1.29.0",
"uuid": "^9.0.1"
"uuid": "^9.0.1",
"vite": "^4.4.11"
}
}

11
public/index.html Normal file
View file

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script src="https://unpkg.com/filer"></script>
</body>
</html>

View file

@ -22,7 +22,7 @@ export default class EditorApp implements App {
version = '1.0.0'
async open (data?: EditorConfig): Promise<FlowWindow> {
const { default: fs } = await import('fs')
const fs = new (window as any).Filer.FileSystem()
const win = (window as any).wm.createWindow({
title: this.name,

View file

@ -4,6 +4,8 @@ import { App } from '../types.ts'
import flow from '../flow.ts'
import { FlowWindow } from '../wm.ts'
import { Stats } from 'fs'
export default class FilesApp implements App {
name = 'Files'
pkg = 'flow.files'
@ -11,7 +13,7 @@ export default class FilesApp implements App {
version = '1.0.0'
async open (): Promise<FlowWindow> {
const { default: fs } = await import('fs')
const fs = new (window as any).Filer.FileSystem()
const win = (window as any).wm.createWindow({
title: this.name,
@ -34,7 +36,7 @@ export default class FilesApp implements App {
win.content.style.flexDirection = 'column'
async function setDir (dir: string): Promise<void> {
await fs.readdir(dir, (e, files) => {
await fs.readdir(dir, (e: NodeJS.ErrnoException, files: string[]) => {
const back = dir === '/' ? '<i class=\'bx bx-arrow-to-left\'></i>' : '<i class=\'back bx bx-left-arrow-alt\'></i>'
win.content.innerHTML = `
@ -54,7 +56,7 @@ export default class FilesApp implements App {
for (const file of files) {
const separator = dir === '/' ? '' : '/'
fs.stat(dir + separator + file, (e, fileStat) => {
fs.stat(dir + separator + file, (e: NodeJS.ErrnoException, fileStat: Stats) => {
const element = document.createElement('div')
element.setAttribute('style', 'padding: 5px;border-bottom: 1px solid var(--text);display:flex;align-items:center;gap: 5px;')

5
src/files.d.ts vendored
View file

@ -1,4 +1 @@
declare module '*.png';
declare module '*.svg';
declare module '*.jpeg';
declare module '*.jpg';
declare module '*.png'

View file

@ -4,7 +4,7 @@
"outDir": "./dist/",
"sourceMap": true,
"noImplicitAny": true,
"module": "ES2022",
"module": "CommonJS",
"target": "ESNext",
"jsx": "react",
"jsxFactory": "h",

21
vite.config.js Normal file
View file

@ -0,0 +1,21 @@
import { defineConfig } from 'vite'
import { createHtmlPlugin } from 'vite-plugin-html'
import { nodePolyfills } from 'vite-plugin-node-polyfills'
import { viteRequire } from 'vite-require'
export default defineConfig({
plugins: [
createHtmlPlugin({
entry: 'src/index.ts',
template: 'public/index.html',
inject: {
data: {
title: 'index',
injectScript: '<script src="./bundle.js"></script>'
}
}
}),
nodePolyfills(),
viteRequire()
]
})