-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
1,497 additions
and
831 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,9 @@ | ||
import fs from 'fs' | ||
import path from 'path' | ||
import { UserConfig } from 'vite' | ||
import { defineConfig } from 'vite' | ||
import prefresh from '@prefresh/vite' | ||
import windicss from 'vite-plugin-windicss' | ||
import { createConfig } from '../scripts/utils' | ||
|
||
const pkg = require('../package.json') | ||
|
||
function getPrismLanguages() { | ||
const files = fs.readdirSync('node_modules/prismjs/components') | ||
return files | ||
.filter((file) => file.endsWith('.min.js')) | ||
.map((file) => { | ||
const [, name] = /\-([^\.]+)/.exec(file)! | ||
return name | ||
}) | ||
} | ||
|
||
const config: UserConfig = { | ||
define: { | ||
DOCUP_VERSION: JSON.stringify(pkg.version), | ||
PRISM_VERSION: JSON.stringify(require('prismjs/package').version), | ||
PRISM_LANGUAGES: JSON.stringify(getPrismLanguages()), | ||
}, | ||
esbuild: { | ||
jsxFactory: 'h', | ||
jsxFragment: 'Fragment', | ||
}, | ||
resolve: { | ||
alias: { | ||
renderer: | ||
process.env.NODE_ENV === 'fre' | ||
? path.resolve('src/renderer/fre.ts') | ||
: path.resolve('src/renderer/preact.ts'), | ||
}, | ||
}, | ||
plugins: [ | ||
prefresh(), | ||
windicss({ | ||
scan: { | ||
fileExtensions: ['tsx'], | ||
dirs: [path.resolve('src')], | ||
}, | ||
}), | ||
], | ||
build: { | ||
target: ['es2020', 'safari14', 'chrome88'], | ||
minify: !process.env.DEBUG, | ||
polyfillDynamicImport: false, | ||
rollupOptions: { | ||
input: [ | ||
path.join(__dirname, 'main.ts'), | ||
path.join(__dirname, 'index.html'), | ||
], | ||
preserveEntrySignatures: 'strict', | ||
output: { | ||
// Disable vendor chunk, make everything bundled in a single file | ||
manualChunks: undefined, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
export default config | ||
export default defineConfig({ | ||
...createConfig('preact', false), | ||
// @ts-expect-error | ||
plugins: [prefresh()], | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.