Commit 629e31f0 authored by lipengcheng 's avatar lipengcheng

feat(vue.confi.js): 配置lodash按需引入

parent 492d3157
module.exports = {
presets: ['@vue/cli-plugin-babel/preset']
presets: ['@vue/cli-plugin-babel/preset'],
plugins: ['lodash']
}
......@@ -31,13 +31,16 @@
},
"dependencies": {
"axios": "^0.20.0",
"babel-plugin-lodash": "^3.3.4",
"core-js": "^3.6.5",
"lodash": "^4.17.20",
"lodash-webpack-plugin": "^0.11.5",
"register-service-worker": "^1.7.1",
"vue": "^2.6.11",
"vue-bus": "^1.2.1",
"vue-js-modal": "^2.0.0-rc.6",
"vue-router": "^3.2.0",
"vuex": "^3.4.0",
"vue-js-modal": "^2.0.0-rc.6"
"vuex": "^3.4.0"
},
"config": {
"commitizen": {
......
import defaultLayout from '@/components/layout/default.vue'
import layoutA from '@/components/layout/layoutA.vue'
// const install = Vue => {
const requireComponent = require.context('.', true, /\.vue/)
console.log('requireComponent:', requireComponent)
// requireComponent.keys().forEach(filename => {
// // 每个文件的详细信息
// const config = requireComponent(filename)
// Vue.component(config.default.name, config.default)
// })
// }
export default [defaultLayout, layoutA]
// export default {
// install
// }
// console.log(`procdfdess.env1:`, process.env);
console.log('process.env.NODE_ENV1:', process.env.NODE_ENV)
const LodashModuleReplacementPlugin = require('lodash-webpack-plugin')
module.exports = {
// outputDir: process.env.outputDir,
// assetsDir: 'static',
......@@ -21,13 +22,30 @@ module.exports = {
}
},
chainWebpack: (config) => {
if (process.env.NODE_ENV === 'production') {
config.plugin('lodashReplace').use(new LodashModuleReplacementPlugin())
// // 去除 console.log
// config.plugin('uglify').tap(([options]) => {
// return [
// Object.assign(options, {
// uglifyOptions: {
// compress: {
// drop_console: true,
// pure_funcs: ['console.log']
// }
// }
// })
// ]
// })
}
config.module
.rule('eslint')
.use('eslint-loader')
.loader('eslint-loader')
.tap((options) => {
// 保存自动eslint修复
options.fix = true
options.fix = false
return options
})
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment