Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
template_vue
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
胡宝山
template_vue
Commits
f7ecbb2b
Commit
f7ecbb2b
authored
Mar 12, 2024
by
高宇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.全局清空console.log
2. 压缩打包文件 3.配置移动端控制台
parent
f9b71eea
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
75 additions
and
1 deletion
+75
-1
README.md
README.md
+75
-1
No files found.
README.md
View file @
f7ecbb2b
...
@@ -46,3 +46,77 @@ npm run lint
...
@@ -46,3 +46,77 @@ npm run lint
# 代码格式检查并自动修复
# 代码格式检查并自动修复
npm run lint
--
--fix
npm run lint
--
--fix
```
```
## 全局清空console.log
1.
在main.js文件中配置以下代码
```
js
if
(
process
.
env
.
NODE_ENV
===
'production'
)
{
if
(
window
)
{
window
.
console
.
log
=
function
()
{}
}
}
```
如果想只在某个特地环境将console.log清空,只需替换production即可
例如 将开发环境的console.log清空
把production替换成.env.development文件中 ENV的值即可
## 压缩打包文件
1.
在package.json引入依赖
```
json
"crypto-js"
:
"4.1.1"
,
"compression-webpack-plugin"
:
"^1.1.12"
,
```
2
.
vue.config.js
中配置以下代码
```js
const
CompressionWebpackPlugin
=
require('compression-webpack-plugin')
const
productionGzipExtensions
=
[
'js'
,
'css'
]
configureWebpack
:
{
plugins
:
[
new
CompressionWebpackPlugin(
{
filename
:
'
[
path
]
.gz
[
query
]
'
,
//
提示compression-webpack-plugin@
3.0
.
0
的话asset改为filename
algorithm
:
'gzip'
,
test
:
new
RegExp('\\.('
+
productionGzipExtensions.join('|')
+
')$')
,
threshold
:
10240
,
minRatio
:
0.8
}
)
]
}
```
3
.在vue.config.js文件configureWebpack对象配置
以下代码
```
js
plugins:
[
new CompressionWebpackPlugin({
filename: '
[
path
]
.gz
[
query
]
', // 提示compression-webpack-plugin@3.0.0的话asset改为filename
algorithm: 'gzip',
test: new RegExp('
\\
.(' + productionGzipExtensions.join('|') + ')$'),
threshold: 10240,
minRatio: 0.8
})
]
```
4. 如果想关闭压缩文件 将第3步注释掉即可
## 配置移动端控制台
1. 位置 在public文件加下添加 vconsole.min.js文件
2. 在 public/index.html 文件夹下配置以下两行代码
```
html
<script
src=
"./vconsole.min.js"
></script>
<script>
new VConsole()
</script>
```
3.
去掉移动端控制台 将第二步代码注释掉即可
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment