Skip to content

Commit c1dc731

Browse files
committed
基座打磨,更新版本
1 parent 731d2a1 commit c1dc731

File tree

4 files changed

+36
-35
lines changed

4 files changed

+36
-35
lines changed

.eslintrc.js

+21-24
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ module.exports = {
33
env: {
44
node: true,
55
},
6-
extends: ["plugin:vue/essential", "eslint:recommended", "@vue/prettier"],
6+
extends: ['plugin:vue/essential', 'eslint:recommended', '@vue/prettier'],
77
// 【parserOptions】扩展 ESLint 对 JavaScript 新语法和实验性特性的支持
88
parserOptions: {
9-
parser: "babel-eslint",
9+
parser: 'babel-eslint',
1010
ecmaFeatures: {
1111
// 支持装饰器
1212
legacyDecorators: true,
@@ -36,55 +36,55 @@ module.exports = {
3636
/* prettier的配置说明 ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ */
3737

3838
rules: {
39-
"prettier/prettier": [
40-
"error",
39+
'prettier/prettier': [
40+
'error',
4141
{
4242
semi: false,
4343
singleQuote: true,
4444
tabWidth: 2,
4545
printWidth: 120,
46-
arrowParens: "avoid",
46+
arrowParens: 'avoid',
4747
bracketSpacing: true,
4848
insertPragma: false,
4949
jsxBracketSameLine: false,
5050
jsxSingleQuote: false,
51-
proseWrap: "preserve",
52-
quoteProps: "as-needed",
51+
proseWrap: 'preserve',
52+
quoteProps: 'as-needed',
5353
requirePragma: false,
54-
trailingComma: "none",
54+
trailingComma: 'none',
5555
useTabs: false,
5656
},
5757
],
58-
"no-console": process.env.NODE_ENV === "production" ? "warn" : "off",
59-
"no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off",
58+
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
59+
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
6060
// 使用2个空格缩进
6161
indent: [
62-
"error",
62+
'error',
6363
2,
6464
{
6565
SwitchCase: 1,
6666
flatTernaryExpressions: true,
6767
},
6868
],
6969
// 代码后不使用分号
70-
semi: ["error", "never"],
70+
semi: ['error', 'never'],
7171
// 注释 // 或 /* 之后必须有一个空格
72-
"spaced-comment": ["error", "always"],
72+
'spaced-comment': ['error', 'always'],
7373
// 必须使用let 或 const, 不能使用var
74-
"no-var": "error",
74+
'no-var': 'error',
7575
quotes: [
76-
"warn",
77-
"single",
76+
'warn',
77+
'single',
7878
{
7979
avoidEscape: true,
8080
allowTemplateLiterals: true,
8181
},
8282
],
8383
// 禁止重复导入模块,对于同一模块内内容,应一次导入
84-
"no-duplicate-imports": "error",
84+
'no-duplicate-imports': 'error',
8585
// 箭头函数前后必须要有空格
86-
"arrow-spacing": [
87-
"error",
86+
'arrow-spacing': [
87+
'error',
8888
{
8989
before: true,
9090
after: true,
@@ -94,13 +94,10 @@ module.exports = {
9494
// overrides 字段的作用是为特定文件或目录定义独立的规则,允许你对不同文件类型或路径应用不同的代码检查规则
9595
overrides: [
9696
{
97-
files: [
98-
"**/__tests__/*.{j,t}s?(x)",
99-
"**/tests/unit/**/*.spec.{j,t}s?(x)",
100-
],
97+
files: ['**/__tests__/*.{j,t}s?(x)', '**/tests/unit/**/*.spec.{j,t}s?(x)'],
10198
env: {
10299
jest: true,
103100
},
104101
},
105102
],
106-
}
103+
}

babel.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module.exports = {
2-
presets: ['@vue/cli-plugin-babel/preset']
2+
presets: ['@vue/cli-plugin-babel/preset'],
33
}

jest.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module.exports = {
2-
preset: '@vue/cli-plugin-unit-jest'
2+
preset: '@vue/cli-plugin-unit-jest',
33
}

vue.config.js

+13-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
'use strict'
2+
const { defineConfig } = require('@vue/cli-service') // 你也可以使用 @vue/cli-service 提供的 defineConfig 帮手函数,以获得更好的类型提示
23
const webpack = require('webpack')
34
const path = require('path')
45

@@ -9,7 +10,8 @@ function resolve(dir) {
910
const port = process.env.PORT || 8888 // 端口
1011

1112
// All configuration item explanations can be find in https://cli.vuejs.org/config/
12-
module.exports = {
13+
// 你也可以使用 @vue/cli-service 提供的 defineConfig 帮手函数,以获得更好的类型提示
14+
module.exports = defineConfig({
1315
/**
1416
* You will need to set publicPath if you plan to deploy your site under a sub path,
1517
* for example GitHub Pages. If you plan to deploy your site to https://foo.github.io/bar/,
@@ -60,15 +62,17 @@ module.exports = {
6062
},
6163
chainWebpack(config) {
6264
// it can improve the speed of the first screen, it is recommended to turn on preload
63-
config.plugin('preload').tap(() => [
64-
{
65-
rel: 'preload',
66-
// to ignore runtime.js
65+
// 通过 preload 预加载关键资源,让浏览器提前下载首屏所需的核心文件(如主 JS、CSS),减少用户等待时间
66+
config.plugin('preload').tap((options) => {
67+
options[0] = {
68+
rel: 'preload', // 预加载类型
69+
// to ignore runtime.js (// 排除不需要预加载的文件)
6770
// https://github.com/vuejs/vue-cli/blob/dev/packages/@vue/cli-service/lib/config/app.js#L171
6871
fileBlacklist: [/\.map$/, /hot-update\.js$/, /runtime\..*\.js$/],
69-
include: 'initial',
70-
},
71-
])
72+
include: 'initial', // 仅预加载"初始块"(首屏关键资源)
73+
}
74+
return options
75+
})
7276

7377
// config.plugin('provide').use(webpack.ProvidePlugin, [{
7478
// 'window.Quill': 'quill/dist/quill.js',
@@ -130,4 +134,4 @@ module.exports = {
130134
config.optimization.runtimeChunk('single')
131135
})
132136
},
133-
}
137+
})

0 commit comments

Comments
 (0)