diff --git a/nuxt.config.js b/nuxt.config.js index 9a66310..012ef54 100644 --- a/nuxt.config.js +++ b/nuxt.config.js @@ -1,6 +1,7 @@ import appConfig from './config/app.config' import apiConfig from './config/api.config' import {isDevMode} from './environment' +const LodashModuleReplacementPlugin = require('lodash-webpack-plugin') export default { /* @@ -86,5 +87,16 @@ export default { */ build: { 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'] + } } } diff --git a/package.json b/package.json index b450297..2812da7 100644 --- a/package.json +++ b/package.json @@ -6,11 +6,13 @@ "dev": "nuxt", "build": "nuxt build", "start": "nuxt start", - "generate": "nuxt generate" + "generate": "nuxt generate", + "analyze": "nuxt build -a" }, "dependencies": { "@chenfengyuan/vue-qrcode": "^1.0.2", "@nuxtjs/axios": "^5.12.1", + "babel-plugin-lodash": "^3.3.4", "cookieparser": "^0.1.0", "echarts": "^4.8.0", "element-ui": "^2.13.2", @@ -25,6 +27,7 @@ }, "devDependencies": { "@nuxtjs/proxy": "^2.0.1", + "lodash-webpack-plugin": "^0.11.5", "node-sass": "^4.14.1", "sass-loader": "^9.0.3" }