Skip to content

Commit

Permalink
[📲] Switched to vite
Browse files Browse the repository at this point in the history
  • Loading branch information
ThinLiquid committed Oct 16, 2023
1 parent 126c2ae commit 9bef524
Show file tree
Hide file tree
Showing 8 changed files with 4,056 additions and 608 deletions.
4,599 changes: 4,007 additions & 592 deletions package-lock.json

Large diffs are not rendered by default.

16 changes: 9 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand All @@ -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": {
Expand All @@ -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 changes: 11 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -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>
2 changes: 1 addition & 1 deletion src/apps/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 5 additions & 3 deletions src/apps/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ 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'
icon = icon
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,
Expand All @@ -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 = `
Expand All @@ -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;')

Expand Down
5 changes: 1 addition & 4 deletions src/files.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
declare module '*.png';
declare module '*.svg';
declare module '*.jpeg';
declare module '*.jpg';
declare module '*.png'
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"outDir": "./dist/",
"sourceMap": true,
"noImplicitAny": true,
"module": "ES2022",
"module": "CommonJS",
"target": "ESNext",
"jsx": "react",
"jsxFactory": "h",
Expand Down
21 changes: 21 additions & 0 deletions vite.config.js
Original file line number Diff line number Diff line change
@@ -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()
]
})

0 comments on commit 9bef524

Please sign in to comment.