refactor: export

master
xiaojunnuo 2021-02-09 18:40:29 +08:00
parent c3e374e6e5
commit b8000ca533
7 changed files with 161 additions and 20 deletions

View File

@ -20,6 +20,8 @@ app.use(bodyparser({
}))
app.use(json())
app.use(logger())
// gzip
// app.use(compress({ threshold: 5120 }))
const staticPlugin = Static(pathUtil.join('public'), {
maxage: 30 * 24 * 60 * 3600,
@ -27,9 +29,6 @@ const staticPlugin = Static(pathUtil.join('public'), {
})
app.use(staticPlugin)
// gzip
app.use(compress({ threshold: 2048 }))
// logger
app.use(async (ctx, next) => {
const start = new Date()

View File

@ -1,9 +1,9 @@
module.exports = {
presets: [
'@vue/cli-plugin-babel/preset'
],
plugins: [['import', {
libraryName: 'ant-design-vue',
style: true // or 'css'
}]]
]
// plugins: [['import', {
// libraryName: 'ant-design-vue',
// style: true // or 'css'
// }]]
}

View File

@ -5198,6 +5198,125 @@
}
}
},
"compression-webpack-plugin": {
"version": "5.0.2",
"resolved": "https://registry.npmjs.org/compression-webpack-plugin/-/compression-webpack-plugin-5.0.2.tgz",
"integrity": "sha512-F2G4cQfsMZ6CiPlG22Q5EDUCqnfyZqTjyJP5cMgNYUbBg/dUzV3hto8yTFFIogDCTWooVbePHQE0qL6FrJUSsA==",
"dev": true,
"requires": {
"cacache": "^15.0.5",
"find-cache-dir": "^3.3.1",
"schema-utils": "^2.7.0",
"serialize-javascript": "^4.0.0",
"webpack-sources": "^1.4.3"
},
"dependencies": {
"cacache": {
"version": "15.0.5",
"resolved": "https://registry.npmjs.org/cacache/-/cacache-15.0.5.tgz",
"integrity": "sha512-lloiL22n7sOjEEXdL8NAjTgv9a1u43xICE9/203qonkZUCj5X1UEWIdf2/Y0d6QcCtMzbKQyhrcDbdvlZTs/+A==",
"dev": true,
"requires": {
"@npmcli/move-file": "^1.0.1",
"chownr": "^2.0.0",
"fs-minipass": "^2.0.0",
"glob": "^7.1.4",
"infer-owner": "^1.0.4",
"lru-cache": "^6.0.0",
"minipass": "^3.1.1",
"minipass-collect": "^1.0.2",
"minipass-flush": "^1.0.5",
"minipass-pipeline": "^1.2.2",
"mkdirp": "^1.0.3",
"p-map": "^4.0.0",
"promise-inflight": "^1.0.1",
"rimraf": "^3.0.2",
"ssri": "^8.0.0",
"tar": "^6.0.2",
"unique-filename": "^1.1.1"
}
},
"chownr": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz",
"integrity": "sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==",
"dev": true
},
"lru-cache": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
"integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==",
"dev": true,
"requires": {
"yallist": "^4.0.0"
}
},
"mkdirp": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz",
"integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==",
"dev": true
},
"p-map": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/p-map/-/p-map-4.0.0.tgz",
"integrity": "sha512-/bjOqmgETBYB5BoEeGVea8dmvHb2m9GLy1E9W43yeyfP6QQCZGFNa+XRceJEuDB6zqr+gKpIAmlLebMpykw/MQ==",
"dev": true,
"requires": {
"aggregate-error": "^3.0.0"
}
},
"rimraf": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz",
"integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==",
"dev": true,
"requires": {
"glob": "^7.1.3"
}
},
"serialize-javascript": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-4.0.0.tgz",
"integrity": "sha512-GaNA54380uFefWghODBWEGisLZFj00nS5ACs6yHa9nLqlLpVLO8ChDGeKRjZnV4Nh4n0Qi7nhYZD/9fCPzEqkw==",
"dev": true,
"requires": {
"randombytes": "^2.1.0"
}
},
"source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
"dev": true
},
"ssri": {
"version": "8.0.1",
"resolved": "https://registry.npmjs.org/ssri/-/ssri-8.0.1.tgz",
"integrity": "sha512-97qShzy1AiyxvPNIkLWoGua7xoQzzPjQ0HAH4B0rWKo7SZ6USuPcrUiAFrws0UH8RrbWmgq3LMTObhPIHbbBeQ==",
"dev": true,
"requires": {
"minipass": "^3.1.1"
}
},
"webpack-sources": {
"version": "1.4.3",
"resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-1.4.3.tgz",
"integrity": "sha512-lgTS3Xhv1lCOKo7SA5TjKXMjpSM4sBjNV5+q2bqesbSPs5FjGmU6jjtBSkX9b4qW87vDIsCIlUPOEhbZrMdjeQ==",
"dev": true,
"requires": {
"source-list-map": "^2.0.0",
"source-map": "~0.6.1"
}
},
"yallist": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
"dev": true
}
}
},
"compute-scroll-into-view": {
"version": "1.0.16",
"resolved": "https://registry.npmjs.org/compute-scroll-into-view/-/compute-scroll-into-view-1.0.16.tgz",

View File

@ -33,6 +33,7 @@
"babel-eslint": "^10.1.0",
"babel-plugin-import": "^1.13.3",
"chai": "^4.2.0",
"compression-webpack-plugin": "^5.0.1",
"eslint": "^7.15.0",
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-node": "^11.1.0",

View File

@ -14,7 +14,6 @@ import {
Divider,
Dropdown,
Form,
Icon,
Input,
InputNumber,
Layout,
@ -51,7 +50,6 @@ const list = {
Divider,
Dropdown,
Form,
Icon,
Input,
InputNumber,
Layout,
@ -78,11 +76,11 @@ export default function (app) {
//
// app.config.globalProperties.$message = message
// app.config.globalProperties.$notification = notification
// app.config.globalProperties.$info = Modal.info
// app.config.globalProperties.$success = Modal.success
// app.config.globalProperties.$error = Modal.error
// app.config.globalProperties.$warning = Modal.warning
// app.config.globalProperties.$confirm = Modal.confirm
// app.config.globalProperties.$destroyAll = Modal.destroyAll
app.config.globalProperties.$info = Modal.info
app.config.globalProperties.$success = Modal.success
app.config.globalProperties.$error = Modal.error
app.config.globalProperties.$warning = Modal.warning
app.config.globalProperties.$confirm = Modal.confirm
app.config.globalProperties.$destroyAll = Modal.destroyAll
})
}

View File

@ -1,16 +1,16 @@
import { createApp } from 'vue'
import router from './router'
import App from './App.vue'
import Antd from 'ant-design-vue'
import 'ant-design-vue/dist/antd.css'
import './style/common.less'
import { i18n } from './i18n'
import icons from './icons'
import antdv from './antdv'
import components from './components'
const app = createApp(App)
app.config.productionTip = false
app.use(i18n)
app.use(Antd)
icons(app)
antdv(app)
// eslint-disable-next-line
import './style/common.less'
app.use(components)
app.use(router).mount('#app')

View File

@ -1,4 +1,11 @@
const CompressionWebpackPlugin = require('compression-webpack-plugin')
// 设置不参与构建的库
const externals = {}
// cdnDependencies.forEach(pkg => { externals[pkg.name] = pkg.library })
module.exports = {
lintOnSave: true,
pages: {
index: {
entry: 'src/main.js',
@ -19,5 +26,22 @@ module.exports = {
javascriptEnabled: true
}
}
},
configureWebpack: config => {
const configNew = {}
if (process.env.NODE_ENV === 'production') {
configNew.externals = externals
configNew.plugins = [
// gzip
new CompressionWebpackPlugin({
filename: '[path].gz[query]',
test: new RegExp('\\.(' + ['js', 'css'].join('|') + ')$'),
threshold: 5120,
minRatio: 0.8,
deleteOriginalAssets: false
})
]
}
return configNew
}
}