feat: compress:true

This commit is contained in:
mozzie 2023-02-22 17:59:35 +08:00
parent 007ac1b4d3
commit 6f0af99c4f
8 changed files with 92 additions and 69 deletions

View File

@ -2,6 +2,7 @@
"name": "@backset/server",
"version": "1.0.0",
"private": true,
"sideEffects": false,
"dependencies": {
"@backset/ui": "workspace:^1.0.0",
"@backset/util": "workspace:^1.0.0",
@ -22,7 +23,9 @@
"typeorm": "~0.3.0",
"mysql2": "3.0.1",
"dotenv": "16.0.3",
"jsonwebtoken": "9.0.0"
"jsonwebtoken": "9.0.0",
"cash-dom": "8.1.3",
"axios": "1.3.3"
},
"devDependencies": {
"@midwayjs/cli": "^2.0.0",
@ -34,8 +37,7 @@
"@types/mongoose": "^5.11.97",
"@typescript-eslint/eslint-plugin": "^5.0.0",
"@typescript-eslint/parser": "^5.0.0",
"@types/jsonwebtoken": "9.0.1",
"@types/jquery": "3.5.16"
"@types/jsonwebtoken": "9.0.1"
},
"engines": {
"node": ">=12.0.0"

View File

@ -1,7 +1,8 @@
<script src="public/vendors.js" crossorigin="anonymous"></script>
<script src="public/chunk-lib.js" crossorigin="anonymous"></script>
<!-- <script src="public/chunk-lib.js" crossorigin="anonymous"></script> -->
<script src="https://code.jquery.com/jquery-3.6.3.min.js"></script>
<!-- <script src="https://code.jquery.com/jquery-3.6.3.min.js"></script> -->
<script
type="text/javascript"

View File

@ -1,5 +1,5 @@
import './index.less';
import $ from 'jquery';
import $ from 'cash-dom';
import '@backset/ui/src/components/Tooltip/index.less';
$(function () {

View File

@ -1,6 +1,6 @@
import './index.less';
import { RegUtil } from '@backset/util';
import $ from 'jquery';
import $ from 'cash-dom';
$(() => {
$('#page-signup')
@ -17,12 +17,12 @@ $(() => {
if (!RegUtil.PHONE.test(params.phone)) return;
// return message.error({ text: '手机号格式错误' });
$('#btn-verify-code').addClass('loading');
$.post('/sms/verify', params, res => {
console.log(res);
if (res) {
$('#btn-verify-code').removeClass('loading');
}
});
// $.post('/sms/verify', params, res => {
// console.log(res);
// if (res) {
// $('#btn-verify-code').removeClass('loading');
// }
// });
}
/**
@ -34,9 +34,9 @@ $(() => {
user_login: '' + $('#tel').val(),
verify_code: '' + $('#verify-code').val(),
};
$.post('/auth/user/login', params, res => {
console.log(res);
});
// $.post('/auth/user/login', params, res => {
// console.log(res);
// });
}
/**
@ -48,9 +48,9 @@ $(() => {
user_login: '' + $('#username').val(),
user_pass: '' + $('#password').val(),
};
$.post('/auth/user/login', params, res => {
console.log(res);
});
// $.post('/auth/user/login', params, res => {
// console.log(res);
// });
}
/**

View File

@ -1,6 +1,7 @@
import './index.less';
import { RegUtil, ValidateUtil } from '@backset/util';
import $ from 'jquery';
import $ from 'cash-dom';
import axios from 'axios';
$(function () {
$('#signup-module').on('click', '#btn-signup', handleCreateUser);
@ -18,7 +19,10 @@ $(function () {
// return message.error({ text: '请补全表单' });
if (!RegUtil.PHONE.test(params.user_phone)) return;
// return message.error({ text: '手机号格式错误' });
$.post('/user/create', params, res => {
// $.post('/user/create', params, res => {
// console.log(res);
// });
axios.post('/user/create', params).then(res => {
console.log(res);
});
}

View File

@ -7,6 +7,8 @@ const CopyPlugin = require('copy-webpack-plugin');
const TerserPlugin = require("terser-webpack-plugin");
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const isDev = process.env.RUNNING_ENV === 'dev';
console.log('isDev', isDev)
const isProd = process.env.RUNNING_ENV === 'prod';
/**
* 引入 src/view/pages下的页面文件排除 _ 开头的文件夹
*/
@ -33,11 +35,14 @@ module.exports = {
chunkFilename: '[id].chunk.js?[hash:8]',
clean: true
},
devtool: 'eval-source-map',
mode: isDev ? 'development' : 'production',
optimization: {
minimize: true,
minimizer: [new TerserPlugin()],
minimizer: [new TerserPlugin({
terserOptions: {
compress: true,
},
})],
splitChunks: {
chunks: 'all',
cacheGroups: {
@ -47,18 +52,18 @@ module.exports = {
priority: 10,
chunks: 'initial'
},
// lib: {
// test(module) {
// return (
// module.size() > 30 * 1024 &&
// /node_modules[/\\]/.test(module.nameForCondition() || '')
// )
// },
// name: 'chunk-lib',
// priority: 15,
// minChunks: 1,
// reuseExistingChunk: true,
// },
lib: {
test(module) {
return (
module.size() > 50 * 1024 &&
/node_modules[/\\]/.test(module.nameForCondition() || '')
)
},
name: 'chunk-lib',
priority: 15,
minChunks: 1,
reuseExistingChunk: true,
},
}
},
},
@ -69,11 +74,6 @@ module.exports = {
use: 'ts-loader',
exclude: /node_modules/,
},
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/,
},
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader'],
@ -125,7 +125,7 @@ module.exports = {
new CopyPlugin([
{ from: join(process.cwd(), 'view/assets'), to: 'assets' },
]),
new BundleAnalyzerPlugin({
isProd && new BundleAnalyzerPlugin({
analyzerHost: "0.0.0.0",
analyzerPort: 8088
})
@ -137,7 +137,7 @@ module.exports = {
externals: {
// require("jquery") 是外部的,并且可用
// 在全局变量 jQuery 上
jquery: 'jQuery',
$: 'jQuery'
// jquery: 'jQuery',
// $: 'jQuery'
},
};

View File

@ -23,7 +23,6 @@
"babel-loader": "8.1.0",
"ts-loader": "9.4.2",
"url-loader": "4.1.1",
"@babel/core": "7.20.12",
"mini-css-extract-plugin": "2.7.2",
"less": "3.8.0",
"less-loader": "4.1.0",

View File

@ -4,7 +4,6 @@ importers:
.:
specifiers:
'@babel/core': 7.20.12
'@types/node': ^18.13.0
autoprefixer: 10.4.13
babel-loader: 8.1.0
@ -33,10 +32,9 @@ importers:
dependencies:
object-hash: registry.npmmirror.com/object-hash/3.0.0
devDependencies:
'@babel/core': registry.npmmirror.com/@babel/core/7.20.12
'@types/node': registry.npmmirror.com/@types/node/18.13.0
autoprefixer: registry.npmmirror.com/autoprefixer/10.4.13
babel-loader: registry.npmmirror.com/babel-loader/8.1.0_la66t7xldg4uecmyawueag5wkm
babel-loader: registry.npmmirror.com/babel-loader/8.1.0_webpack@5.75.0
chalk: registry.npmmirror.com/chalk/4.1.2
copy-webpack-plugin: registry.npmmirror.com/copy-webpack-plugin/5.1.2_webpack@5.75.0
cross-env: registry.npmmirror.com/cross-env/6.0.3
@ -109,13 +107,14 @@ importers:
'@midwayjs/validate': ^3.0.0
'@midwayjs/view-ejs': ^3.0.0
'@typegoose/typegoose': 10.1.1
'@types/jquery': 3.5.16
'@types/jsonwebtoken': 9.0.1
'@types/koa': ^2.13.4
'@types/mongoose': ^5.11.97
'@types/node': '14'
'@typescript-eslint/eslint-plugin': ^5.0.0
'@typescript-eslint/parser': ^5.0.0
axios: 1.3.3
cash-dom: 8.1.3
dotenv: 16.0.3
jsonwebtoken: 9.0.0
mongoose: ^6.0.7
@ -139,6 +138,8 @@ importers:
'@midwayjs/validate': registry.npmmirror.com/@midwayjs/validate/3.10.10
'@midwayjs/view-ejs': registry.npmmirror.com/@midwayjs/view-ejs/3.10.10
'@typegoose/typegoose': registry.npmmirror.com/@typegoose/typegoose/10.1.1_mongoose@6.9.1
axios: registry.npmmirror.com/axios/1.3.3
cash-dom: registry.npmmirror.com/cash-dom/8.1.3
dotenv: registry.npmmirror.com/dotenv/16.0.3
jsonwebtoken: registry.npmmirror.com/jsonwebtoken/9.0.0
mongoose: registry.npmmirror.com/mongoose/6.9.1
@ -147,7 +148,6 @@ importers:
devDependencies:
'@midwayjs/cli': registry.npmmirror.com/@midwayjs/cli/2.0.11_6n5i4uawcmfzplajgd2lmh6r2e
'@midwayjs/mock': registry.npmmirror.com/@midwayjs/mock/3.10.10
'@types/jquery': registry.npmmirror.com/@types/jquery/3.5.16
'@types/jsonwebtoken': registry.npmmirror.com/@types/jsonwebtoken/9.0.1
'@types/koa': registry.npmmirror.com/@types/koa/2.13.5
'@types/mongoose': registry.npmmirror.com/@types/mongoose/5.11.97
@ -2560,14 +2560,6 @@ packages:
version: 2.0.1
dev: true
registry.npmmirror.com/@types/jquery/3.5.16:
resolution: {integrity: sha512-bsI7y4ZgeMkmpG9OM710RRzDFp+w4P1RGiIt30C1mSBT+ExCleeh4HObwgArnDFELmRrOpXgSYN9VF1hj+f1lw==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@types/jquery/-/jquery-3.5.16.tgz}
name: '@types/jquery'
version: 3.5.16
dependencies:
'@types/sizzle': registry.npmmirror.com/@types/sizzle/2.3.3
dev: true
registry.npmmirror.com/@types/json-schema/7.0.11:
resolution: {integrity: sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@types/json-schema/-/json-schema-7.0.11.tgz}
name: '@types/json-schema'
@ -2762,12 +2754,6 @@ packages:
'@types/node': registry.npmmirror.com/@types/node/18.13.0
dev: true
registry.npmmirror.com/@types/sizzle/2.3.3:
resolution: {integrity: sha512-JYM8x9EGF163bEyhdJBpR2QX1R5naCJHC8ucJylJ3w9/CVBaskdQ8WqBf8MmQrd1kRvp/a4TS8HJ+bxzR7ZJYQ==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@types/sizzle/-/sizzle-2.3.3.tgz}
name: '@types/sizzle'
version: 2.3.3
dev: true
registry.npmmirror.com/@types/superagent/4.1.14:
resolution: {integrity: sha512-iiXaOL2wSbnSY4qg0mFPWJHL9iwyEsoNYwaHF2w58/fsVAQJlj+KUfFAFZu+nzbz+b7dUprJEAc+O9vhHHhQTA==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@types/superagent/-/superagent-4.1.14.tgz}
name: '@types/superagent'
@ -3645,7 +3631,6 @@ packages:
resolution: {integrity: sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/asynckit/-/asynckit-0.4.0.tgz}
name: asynckit
version: 0.4.0
dev: true
registry.npmmirror.com/autoprefixer/10.4.13:
resolution: {integrity: sha512-49vKpMqcZYsJjwotvt4+h/BCjJVnhGwcLpDt5xkcaOG3eLrG/HUYLagrihYsQ+qrIBgIzX1Rw7a6L8I/ZA1Atg==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/autoprefixer/-/autoprefixer-10.4.13.tgz}
@ -3678,7 +3663,19 @@ packages:
dev: true
optional: true
registry.npmmirror.com/babel-loader/8.1.0_la66t7xldg4uecmyawueag5wkm:
registry.npmmirror.com/axios/1.3.3:
resolution: {integrity: sha512-eYq77dYIFS77AQlhzEL937yUBSepBfPIe8FcgEDN35vMNZKMrs81pgnyrQpwfy4NF4b4XWX1Zgx7yX+25w8QJA==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/axios/-/axios-1.3.3.tgz}
name: axios
version: 1.3.3
dependencies:
follow-redirects: registry.npmmirror.com/follow-redirects/1.15.2
form-data: registry.npmmirror.com/form-data/4.0.0
proxy-from-env: registry.npmmirror.com/proxy-from-env/1.1.0
transitivePeerDependencies:
- debug
dev: false
registry.npmmirror.com/babel-loader/8.1.0_webpack@5.75.0:
resolution: {integrity: sha512-7q7nC1tYOrqvUrN3LQK4GwSk/TQorZSOlO9C+RZDZpODgyN4ZlCqE5q9cDsyWOliN+aU9B4JX01xK9eJXowJLw==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/babel-loader/-/babel-loader-8.1.0.tgz}
id: registry.npmmirror.com/babel-loader/8.1.0
name: babel-loader
@ -3688,7 +3685,6 @@ packages:
'@babel/core': ^7.0.0
webpack: '>=2'
dependencies:
'@babel/core': registry.npmmirror.com/@babel/core/7.20.12
find-cache-dir: registry.npmmirror.com/find-cache-dir/2.1.0
loader-utils: registry.npmmirror.com/loader-utils/1.4.2
mkdirp: registry.npmmirror.com/mkdirp/0.5.6
@ -3936,6 +3932,12 @@ packages:
dev: true
optional: true
registry.npmmirror.com/cash-dom/8.1.3:
resolution: {integrity: sha512-+W6A9GrgH6do57T/2QLlobr8Q3nwvRoLf74HQRu8zFsyP8hBAjg0RJsubIP+uoV7MYknnugrEdEW5HHH0hJB7Q==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/cash-dom/-/cash-dom-8.1.3.tgz}
name: cash-dom
version: 8.1.3
dev: false
registry.npmmirror.com/chalk/2.4.2:
resolution: {integrity: sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/chalk/-/chalk-2.4.2.tgz}
name: chalk
@ -4184,7 +4186,6 @@ packages:
engines: {node: '>= 0.8'}
dependencies:
delayed-stream: registry.npmmirror.com/delayed-stream/1.0.0
dev: true
registry.npmmirror.com/commander/2.20.3:
resolution: {integrity: sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/commander/-/commander-2.20.3.tgz}
@ -4559,7 +4560,6 @@ packages:
name: delayed-stream
version: 1.0.0
engines: {node: '>=0.4.0'}
dev: true
registry.npmmirror.com/delegates/1.0.0:
resolution: {integrity: sha512-bd2L678uiWATM6m5Z1VzNCErI3jiGzt6HGY8OVICs40JQq/HALfbyNJmp0UDakEY4pMMaN0Ly5om/B1VI/+xfQ==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/delegates/-/delegates-1.0.0.tgz}
@ -5343,6 +5343,18 @@ packages:
version: 1.1.0
dev: false
registry.npmmirror.com/follow-redirects/1.15.2:
resolution: {integrity: sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/follow-redirects/-/follow-redirects-1.15.2.tgz}
name: follow-redirects
version: 1.15.2
engines: {node: '>=4.0'}
peerDependencies:
debug: '*'
peerDependenciesMeta:
debug:
optional: true
dev: false
registry.npmmirror.com/forever-agent/0.6.1:
resolution: {integrity: sha512-j0KLYPhm6zeac4lz3oJ3o65qvgQCcPubiyotZrXqEaG4hNagNYO8qdlUrX5vwqv9ohqeT/Z3j6+yW067yWWdUw==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/forever-agent/-/forever-agent-0.6.1.tgz}
name: forever-agent
@ -5371,7 +5383,6 @@ packages:
asynckit: registry.npmmirror.com/asynckit/0.4.0
combined-stream: registry.npmmirror.com/combined-stream/1.0.8
mime-types: registry.npmmirror.com/mime-types/2.1.35
dev: true
registry.npmmirror.com/formidable/2.1.2:
resolution: {integrity: sha512-CM3GuJ57US06mlpQ47YcunuUZ9jpm8Vx+P2CGt2j7HpgkKZO/DJYQ0Bobim8G6PFQmK5lOqOOdUXboU+h73A4g==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/formidable/-/formidable-2.1.2.tgz}
@ -7833,6 +7844,12 @@ packages:
dev: true
optional: true
registry.npmmirror.com/proxy-from-env/1.1.0:
resolution: {integrity: sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz}
name: proxy-from-env
version: 1.1.0
dev: false
registry.npmmirror.com/prr/1.0.1:
resolution: {integrity: sha512-yPw4Sng1gWghHQWj0B3ZggWUm4qVbPwPFcRG8KyxiU7J2OHFSoEHKS+EZ3fv5l1t9CyCiop6l/ZYeWbrgoQejw==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/prr/-/prr-1.0.1.tgz}
name: prr