⚗️ 网页加载速度优化尝试

This commit is contained in:
ronger 2020-08-12 17:22:23 +08:00
parent 613378434f
commit a267fc3ec1
2 changed files with 16 additions and 1 deletions

View File

@ -1,6 +1,7 @@
import appConfig from './config/app.config' import appConfig from './config/app.config'
import apiConfig from './config/api.config' import apiConfig from './config/api.config'
import {isDevMode} from './environment' import {isDevMode} from './environment'
const LodashModuleReplacementPlugin = require('lodash-webpack-plugin')
export default { export default {
/* /*
@ -86,5 +87,16 @@ export default {
*/ */
build: { build: {
transpile: [/^element-ui/], transpile: [/^element-ui/],
optimization: {
splitChunks: {
minSize: 10000,
maxSize: 250000
}
},
extend(config, ctx) {
config.plugins.unshift(new LodashModuleReplacementPlugin())
// rules[2].use[0] is babel-loader
config.module.rules[2].use[0].options.plugins = ['lodash']
}
} }
} }

View File

@ -6,11 +6,13 @@
"dev": "nuxt", "dev": "nuxt",
"build": "nuxt build", "build": "nuxt build",
"start": "nuxt start", "start": "nuxt start",
"generate": "nuxt generate" "generate": "nuxt generate",
"analyze": "nuxt build -a"
}, },
"dependencies": { "dependencies": {
"@chenfengyuan/vue-qrcode": "^1.0.2", "@chenfengyuan/vue-qrcode": "^1.0.2",
"@nuxtjs/axios": "^5.12.1", "@nuxtjs/axios": "^5.12.1",
"babel-plugin-lodash": "^3.3.4",
"cookieparser": "^0.1.0", "cookieparser": "^0.1.0",
"echarts": "^4.8.0", "echarts": "^4.8.0",
"element-ui": "^2.13.2", "element-ui": "^2.13.2",
@ -25,6 +27,7 @@
}, },
"devDependencies": { "devDependencies": {
"@nuxtjs/proxy": "^2.0.1", "@nuxtjs/proxy": "^2.0.1",
"lodash-webpack-plugin": "^0.11.5",
"node-sass": "^4.14.1", "node-sass": "^4.14.1",
"sass-loader": "^9.0.3" "sass-loader": "^9.0.3"
} }