Merge pull request #1060 from crawlab-team/feature-optimize-frontend-size

Feature optimize frontend size
This commit is contained in:
Marvin Zhang
2022-01-28 16:01:20 +08:00
committed by GitHub
11 changed files with 492 additions and 1305 deletions

View File

@@ -8,5 +8,5 @@ This Disclaimer and privacy protection statement (hereinafter referred to as "di
4. The user shall bear the risk of using crawlab by himself, we do not make any form of guarantee, and we will not bear any legal responsibility for the user's failure to upgrade and update normally due to any technical reasons such as network condition and communication line.
5. When users use crawlab to grab the target website, they need to comply with the laws and regulations related to crawlers, such as the network security law. Do not collect personal information of citizens without authorization, cause the target website to be paralyzed by DDoS, or fail to comply with the robots.txt protocol and other illegal means of the target website.
6. Crawlab respects and protects the personal privacy of all users and will not steal any information from users' computers.
7. Copyright of the system: the crawleb development team owns the intellectual property rights, copyrights, copyrights and use rights for all developed or jointly developed products, which are protected by applicable intellectual property rights, copyrights, trademarks, service trademarks, patents or other laws.
8. Communication: any company or individual who publishes or disseminates our software on the Internet is allowed, but the crawlab development team shall not be responsible for any legal and criminal events that may be caused by the company or individual disseminating the software.
7. Copyright of the system: Crawlab development team owns the intellectual property rights, copyrights, copyrights and use rights for all developed or jointly developed products, which are protected by applicable intellectual property rights, copyrights, trademarks, service trademarks, patents or other laws.
8. Communication: any company or individual who publishes or disseminates our software on the Internet is allowed, but the crawlab development team shall not be responsible for any legal and criminal events that may be caused by the company or individual disseminating the software.

12
backend/.editorconfig Normal file
View File

@@ -0,0 +1,12 @@
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = tab
insert_final_newline = true
trim_trailing_whitespace = true
[{*.yml, *.yaml, *.json}]
indent_size = 2

View File

@@ -1,32 +0,0 @@
SHELL := /bin/bash
BASEDIR = $(shell pwd)
# build with verison infos
versionDir = "apiserver/pkg/version"
gitTag = $(shell if [ "`git describe --tags --abbrev=0 2>/dev/null`" != "" ];then git describe --tags --abbrev=0; else git log --pretty=format:'%h' -n 1; fi)
buildDate = $(shell TZ=Asia/Shanghai date +%FT%T%z)
gitCommit = $(shell git log --pretty=format:'%H' -n 1)
gitTreeState = $(shell if git status|grep -q 'clean';then echo clean; else echo dirty; fi)
ldflags="-w -X ${versionDir}.gitTag=${gitTag} -X ${versionDir}.buildDate=${buildDate} -X ${versionDir}.gitCommit=${gitCommit} -X ${versionDir}.gitTreeState=${gitTreeState}"
all: gotool
@go build -v -ldflags ${ldflags} .
clean:
rm -f apiserver
find . -name "[._]*.s[a-w][a-z]" | xargs -i rm -f {}
gotool:
gofmt -w .
go tool vet . |& grep -v vendor;true
ca:
openssl req -new -nodes -x509 -out conf/server.crt -keyout conf/server.key -days 3650 -subj "/C=DE/ST=NRW/L=Earth/O=Random Company/OU=IT/CN=127.0.0.1/emailAddress=xxxxx@qq.com"
help:
@echo "make - compile the source code"
@echo "make clean - remove binary file and vim swp files"
@echo "make gotool - run go tool 'fmt' and 'vet'"
@echo "make ca - generate ca files"
.PHONY: clean gotool ca help

12
backend/Taskfile.yml Normal file
View File

@@ -0,0 +1,12 @@
version: '3'
tasks:
dev:
desc: Switch to dev mode for local development.
cmds:
- cp -f go.mod.dev go.mod
deploy:
desc: Switch to deploy mode for code publish.
cmds:
- echo 'not implemented'

View File

@@ -2,6 +2,13 @@ module crawlab
go 1.16
replace (
github.com/crawlab-team/crawlab-core => ../../crawlab-core
github.com/crawlab-team/crawlab-vcs => ../../crawlab-vcs
github.com/crawlab-team/crawlab-fs => ../../crawlab-fs
github.com/crawlab-team/crawlab-db => ../../crawlab-db
)
require (
github.com/apex/log v1.9.0
github.com/crawlab-team/crawlab-core v0.6.0-beta.20211230.1200

20
backend/go.mod.dev Normal file
View File

@@ -0,0 +1,20 @@
module crawlab
go 1.16
replace (
github.com/crawlab-team/crawlab-core => ../../crawlab-core
github.com/crawlab-team/crawlab-vcs => ../../crawlab-vcs
github.com/crawlab-team/crawlab-fs => ../../crawlab-fs
github.com/crawlab-team/crawlab-db => ../../crawlab-db
)
require (
github.com/apex/log v1.9.0
github.com/crawlab-team/crawlab-core v0.6.0-beta.20211230.1200
github.com/crawlab-team/go-trace v0.1.1
github.com/gin-gonic/gin v1.7.1
github.com/spf13/cobra v1.1.3
github.com/spf13/viper v1.7.1
go.uber.org/dig v1.10.0
)

View File

@@ -3,16 +3,18 @@ module crawlab
go 1.16
replace (
github.com/crawlab-team/crawlab-core => /Users/chenjingyang/dev/my-job/gitee/crawlab-core
github.com/crawlab-team/goseaweedfs => /Users/chenjingyang/dev/my-job/gitee/goseaweedfs
github.com/crawlab-team/crawlab-core => /libs/crawlab-team/crawlab-core
github.com/crawlab-team/crawlab-vcs => /libs/crawlab-team/crawlab-vcs
github.com/crawlab-team/crawlab-fs => /libs/crawlab-team/crawlab-fs
github.com/crawlab-team/crawlab-db => /libs/crawlab-team/crawlab-db
)
require (
github.com/apex/log v1.9.0
github.com/crawlab-team/crawlab-core v0.6.0-beta.20211230.1200
github.com/crawlab-team/go-trace v0.1.1
github.com/gin-gonic/gin v1.7.1
github.com/spf13/cobra v1.1.3
github.com/spf13/viper v1.7.1
go.uber.org/dig v1.10.0
github.com/apex/log v1.9.0
github.com/crawlab-team/crawlab-core v0.6.0-beta.20211230.1200
github.com/crawlab-team/go-trace v0.1.1
github.com/gin-gonic/gin v1.7.1
github.com/spf13/cobra v1.1.3
github.com/spf13/viper v1.7.1
go.uber.org/dig v1.10.0
)

2
frontend/.env.analyze Normal file
View File

@@ -0,0 +1,2 @@
NODE_ENV='analyze'
VUE_APP_API_BASE_URL=http://localhost:8000

View File

@@ -7,7 +7,8 @@
"serve:dist": "serve dist",
"build": "vue-cli-service build",
"build:development": "vue-cli-service build --mode development",
"build:docker": "vue-cli-service build --mode docker"
"build:docker": "vue-cli-service build --mode docker",
"build:analyze": "vue-cli-service build --mode analyze"
},
"author": {
"name": "Marvin Zhang",
@@ -15,13 +16,24 @@
},
"license": "BSD-3-Clause",
"dependencies": {
"crawlab-ui": "0.6.0-beta.20211229.1830",
"@element-plus/icons": "^0.0.11",
"@fortawesome/fontawesome-svg-core": "^1.2.32",
"@fortawesome/free-brands-svg-icons": "^5.15.1",
"@fortawesome/free-regular-svg-icons": "^5.15.1",
"@fortawesome/free-solid-svg-icons": "^5.15.1",
"@fortawesome/vue-fontawesome": "^3.0.0-4",
"atom-material-icons": "^3.0.0",
"codemirror": "^5.59.1",
"echarts": "^5.1.2",
"element-plus": "^1.2.0-beta.3",
"vue": "3.0.11",
"vue-router": "^4.0.11"
},
"devDependencies": {
"@vue/cli-service": "^4.5.13",
"@vue/compiler-sfc": "^3.0.11",
"serve": "^13.0.2"
"copy-webpack-plugin": "^6.0",
"serve": "^13.0.2",
"webpack-bundle-analyzer": "^4.5.0"
}
}

View File

@@ -1,3 +1,13 @@
const path = require("path")
const CopyWebpackPlugin = require('copy-webpack-plugin')
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
const alias = {
'element-plus$': 'element-plus/dist/index.full.min.js',
'echarts$': 'echarts/dist/echarts.min.js',
'codemirror$': 'codemirror/lib/codemirror.js',
}
const optimization = {
splitChunks: {
chunks: 'initial',
@@ -5,18 +15,13 @@ const optimization = {
minChunks: 1,
maxAsyncRequests: 3,
cacheGroups: {
defaultVendors: {
test: /[\\/]node_modules[\\/]]/,
vendors: {
test: /[\\/]node_modules[\\/]/,
priority: -10,
reuseExistingChunk: true
reuseExistingChunk: true,
},
default: {
minChunks: 2,
priority: -20,
reuseExistingChunk: true
}
}
}
},
},
}
const config = {
@@ -31,8 +36,27 @@ const config = {
outputDir: './dist',
configureWebpack: {
optimization,
resolve: {
alias,
},
plugins: []
}
}
if (['development', 'local'].includes(process.env.NODE_ENV)) {
// do nothing
} else if (['production'].includes(process.env.NODE_ENV)) {
config.configureWebpack.plugins.push(new CopyWebpackPlugin({
patterns: [
{
from: path.resolve(__dirname, 'public/js'),
}
]
}))
} else if (['analyze'].includes(process.env.NODE_ENV)) {
config.configureWebpack.plugins.push(new BundleAnalyzerPlugin({
analyzePort: 8890,
}))
}
module.exports = config

File diff suppressed because it is too large Load Diff