Skip to content
Permalink
Browse files

压缩组件更改

  • Loading branch information...
rongxingsun committed Jun 14, 2019
1 parent bffb5bf commit 34e45251740dd94f597319709ddb9d5ca97e44ce
Showing with 178 additions and 229 deletions.
  1. +0 −1 package.json
  2. +18 −33 vue.config.js
  3. +160 −195 yarn.lock
@@ -68,7 +68,6 @@
"sass-loader": "^7.1.0",
"svg-sprite-loader": "^4.1.6",
"text-loader": "0.0.1",
"uglifyjs-webpack-plugin": "^2.1.3",
"vue-cli-plugin-i18n": "^0.6.0",
"vue-template-compiler": "^2.6.10",
"webpack-theme-color-replacer": "^1.2.5"
@@ -1,4 +1,3 @@
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
const VueFilenameInjector = require('./tools/vue-filename-injector')

const ThemeColorReplacer = require('webpack-theme-color-replacer')
@@ -29,21 +28,14 @@ module.exports = {
}
}
},
// node_modules 需要babel成es5的包
transpileDependencies: [
'webpack-theme-color-replacer'
],
configureWebpack: {
plugins: [
new ThemeColorReplacer({
fileName: 'css/theme-colors.[contenthash:8].css',
matchColors: [
...forElementUI.getElementUISeries(process.env.VUE_APP_ELEMENT_COLOR) // Element-ui主色系列
],
externalCssFiles: [ './node_modules/element-ui/lib/theme-chalk/index.css' ], // optional, String or string array. Set external css files (such as cdn css) to extract colors.
changeSelector: forElementUI.changeSelector
})
]
configureWebpack: config => {
// 非开发环境
if (process.env.NODE_ENV !== 'development') {
config.optimization.minimizer[0].options.terserOptions.compress.warnings = false
config.optimization.minimizer[0].options.terserOptions.compress.drop_console = true
config.optimization.minimizer[0].options.terserOptions.compress.drop_debugger = true
config.optimization.minimizer[0].options.terserOptions.compress.pure_funcs = ['console.log']
}
},
// 默认设置: https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-service/lib/config/base.js
chainWebpack: config => {
@@ -59,6 +51,16 @@ module.exports = {
// 解决 cli3 热更新失效 https://github.com/vuejs/vue-cli/issues/1559
config.resolve
.symlinks(true)
config
.plugin('theme-color-replacer')
.use(ThemeColorReplacer, [{
fileName: 'css/theme-colors.[contenthash:8].css',
matchColors: [
...forElementUI.getElementUISeries(process.env.VUE_APP_ELEMENT_COLOR) // Element-ui主色系列
],
externalCssFiles: [ './node_modules/element-ui/lib/theme-chalk/index.css' ], // optional, String or string array. Set external css files (such as cdn css) to extract colors.
changeSelector: forElementUI.changeSelector
}])
config
// 开发环境
.when(process.env.NODE_ENV === 'development',
@@ -71,23 +73,6 @@ module.exports = {
propName: process.env.VUE_APP_SOURCE_VIEWER_PROP_NAME
})
)
// 非开发环境
.when(process.env.NODE_ENV !== 'development', config => {
config.optimization
.minimizer([
new UglifyJsPlugin({
uglifyOptions: {
// 移除 console
// 其它优化选项 https://segmentfault.com/a/1190000010874406
compress: {
drop_console: true,
drop_debugger: true,
pure_funcs: ['console.log']
}
}
})
])
})
// markdown
config.module
.rule('md')

0 comments on commit 34e4525

Please sign in to comment.
You can’t perform that action at this time.