Skip to content

Commit

Permalink
调整打包参数, 生产打包代码压缩
Browse files Browse the repository at this point in the history
  • Loading branch information
lanyuanxiaoyao committed Dec 8, 2020
1 parent 830559c commit 950a6af
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
1 change: 1 addition & 0 deletions .env.electron
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
VUE_APP_MODE=electron
NODE_ENV=production
1 change: 0 additions & 1 deletion src/components/SiteList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ export default {
scoped
>
.site-list
//margin-left: -50px
width auto
.site-icon
Expand Down
29 changes: 20 additions & 9 deletions vue.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const CopyPlugin = require('copy-webpack-plugin')
const TerserPlugin = require('terser-webpack-plugin')
const path = require('path')

const appMode = process.env.VUE_APP_MODE
Expand All @@ -8,22 +9,32 @@ const isWeb = appMode === 'web'
let distPath = path.join(__dirname, 'dist')
if (appMode === 'utools') distPath = path.join(__dirname, 'dist_utools')

console.log(`Current Node Mode: ${process.env.NODE_ENV}`)
module.exports = {
publicPath: isWeb ? '/' : './',
productionSourceMap: false,
outputDir: distPath,
chainWebpack: config => {
config.plugin('copy-plugin')
.use(CopyPlugin, [
{
patterns: [
{
from: path.join(__dirname, 'README.md'),
to: path.join(distPath, 'README.md'),
.use(CopyPlugin, [{
patterns: [
{
from: path.join(__dirname, 'README.md'),
to: path.join(distPath, 'README.md'),
}
],
}])
if (process.env.NODE_ENV === 'production') {
config.optimization
.minimizer('terser')
.use(TerserPlugin, [{
terserOptions: {
compress: {
pure_funcs: ['console.log']
}
],
}
])
}
}])
}
},
pluginOptions: {
electronBuilder: {
Expand Down

0 comments on commit 950a6af

Please sign in to comment.