mirror of
https://github.com/fumiama/paper-manager.git
synced 2026-06-04 23:40:24 +08:00
implement production build
This commit is contained in:
10
frontend/main.go
Normal file
10
frontend/main.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package frontend
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/fumiama/paper-manager/frontend/vben"
|
||||
)
|
||||
|
||||
// StaticHandler serves contents in frontend
|
||||
var StaticHandler = http.FileServer(vben.Distribution)
|
||||
@@ -32,4 +32,4 @@ VITE_USE_IMAGEMIN= true
|
||||
VITE_USE_PWA = false
|
||||
|
||||
# Is it compatible with older browsers
|
||||
VITE_LEGACY = false
|
||||
VITE_LEGACY = true
|
||||
|
||||
1
frontend/vben/.gitignore
vendored
1
frontend/vben/.gitignore
vendored
@@ -32,3 +32,4 @@ package-lock.json
|
||||
pnpm-lock.yaml
|
||||
|
||||
.vscode
|
||||
dist.zip
|
||||
|
||||
29
frontend/vben/main.go
Normal file
29
frontend/vben/main.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package vben
|
||||
|
||||
import (
|
||||
"archive/zip"
|
||||
"bytes"
|
||||
_ "embed" // embed dist.zip
|
||||
"io/fs"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
//go:generate npm run build
|
||||
|
||||
//go:generate zip -9 -r -D dist.zip dist/* -x "dist/.DS_Store" "dist/*/.DS_Store"
|
||||
|
||||
//go:embed dist.zip
|
||||
var distzipbytes []byte
|
||||
|
||||
// Distribution ...
|
||||
var Distribution = func() http.FileSystem {
|
||||
distzip, err := zip.NewReader(bytes.NewReader(distzipbytes), int64(len(distzipbytes)))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
distfs, err := fs.Sub(fs.FS(distzip), "dist")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return http.FS(distfs)
|
||||
}()
|
||||
@@ -36,7 +36,7 @@
|
||||
import { Card, List } from 'ant-design-vue'
|
||||
import { getMessageList, acceptMessage, deleteMessage } from '/@/api/dashboard/index'
|
||||
import { useMessage } from '/@/hooks/web/useMessage'
|
||||
import { MessageTypeEnum, MessageItem } from '../../../../api/dashboard/model/model.js'
|
||||
import { MessageTypeEnum, MessageItem } from '/@/api/dashboard/model/model'
|
||||
import { Avatar } from 'ant-design-vue'
|
||||
import headerImg from '/@/assets/images/header.jpg'
|
||||
|
||||
|
||||
@@ -64,20 +64,20 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
|
||||
pure: VITE_DROP_CONSOLE ? ['console.log', 'debugger'] : [],
|
||||
},
|
||||
build: {
|
||||
target: 'es2015',
|
||||
target: 'es2022',
|
||||
cssTarget: 'chrome80',
|
||||
outDir: OUTPUT_DIR,
|
||||
// minify: 'terser',
|
||||
minify: 'terser',
|
||||
/**
|
||||
* 当 minify=“minify:'terser'” 解开注释
|
||||
* Uncomment when minify="minify:'terser'"
|
||||
*/
|
||||
// terserOptions: {
|
||||
// compress: {
|
||||
// keep_infinity: true,
|
||||
// drop_console: VITE_DROP_CONSOLE,
|
||||
// },
|
||||
// },
|
||||
terserOptions: {
|
||||
compress: {
|
||||
keep_infinity: true,
|
||||
drop_console: VITE_DROP_CONSOLE,
|
||||
},
|
||||
},
|
||||
// Turning off brotliSize display can slightly reduce packaging time
|
||||
brotliSize: false,
|
||||
chunkSizeWarningLimit: 2000,
|
||||
|
||||
2
main.go
2
main.go
@@ -10,6 +10,7 @@ import (
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/fumiama/paper-manager/backend"
|
||||
"github.com/fumiama/paper-manager/frontend"
|
||||
)
|
||||
|
||||
func line() int {
|
||||
@@ -33,6 +34,7 @@ func main() {
|
||||
http.HandleFunc("/file/", backend.FileHandler)
|
||||
http.HandleFunc("/paper/", backend.PaperHandler)
|
||||
http.HandleFunc("/upload", backend.UploadHandler)
|
||||
http.Handle("/", frontend.StaticHandler)
|
||||
|
||||
logrus.Infoln("[http.Serve] start at", l.Addr())
|
||||
logrus.Errorln("[http.Serve]", http.Serve(l, nil))
|
||||
|
||||
Reference in New Issue
Block a user