Skip to content

Commit

Permalink
tmp ssr
Browse files Browse the repository at this point in the history
  • Loading branch information
lduoduo committed Nov 29, 2020
1 parent 3504758 commit a33d191
Show file tree
Hide file tree
Showing 39 changed files with 582 additions and 13,360 deletions.
33 changes: 23 additions & 10 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,33 @@
module.exports = {
root: true,
env: {
node: true
node: true,
},
extends: [
"plugin:vue/essential",
"eslint:recommended",
"@vue/typescript/recommended",
"@vue/prettier",
"@vue/prettier/@typescript-eslint"
'plugin:vue/essential',
"plugin:prettier/recommended",
'eslint:recommended',
'@vue/typescript/recommended',
'@vue/prettier',
'@vue/prettier/@typescript-eslint',
],
overrides: [
{
files: '**/*.ts',
extends: [
'@vue/typescript/recommended',
'@vue/prettier/@typescript-eslint',
'plugin:@typescript-eslint/recommended',
'prettier/@typescript-eslint',
'prettier',
],
},
],
parserOptions: {
ecmaVersion: 2020
ecmaVersion: 2020,
},
rules: {
"no-console": process.env.NODE_ENV === "production" ? "warn" : "off",
"no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off"
}
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
},
};
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
stats.json

# Editor directories and files
.idea
Expand Down
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"semi": true,
"singleQuote": true
}
29 changes: 23 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,53 @@
## node >= 10.13.0

## Project setup

```
yarn install
```

### Compiles and hot-reloads for development

```
- yarn mock
- yarn serve
```

### Compiles and minifies for production

```
yarn build
```

### Lints and fixes files

```
yarn lint
```

### Customize configuration

See [Configuration Reference](https://cli.vuejs.org/config/).

### 注意点

1. 嵌套子路由:
- 父路由一定要有个模板文件,添加 `<router-view />` 用于展示里面的子路由内容
- 子路由path一定一定一定不要加 '/' 前缀,否则匹配不到
2. mock数据安装:npm install -g json-server
3. 使用vuex-ts版本时,初始访问页面,getter上不一定有值,如果不做兼容会报错

- 父路由一定要有个模板文件,添加 `<router-view />` 用于展示里面的子路由内容
- 子路由 path 一定一定一定不要加 '/' 前缀,否则匹配不到

2. mock 数据安装:npm install -g json-server
3. 使用 vuex-ts 版本时,初始访问页面,getter 上不一定有值,如果不做兼容会报错

### BUG
1. vue Cannot convert object to primitive value
- template上设置本该为string的值为对象

1. vue Cannot convert object to primitive value

- template 上设置本该为 string 的值为对象

2. webpack4 配置 ssr 环境遇到“document is not defined”

- 问题原因:在服务端渲染打包的配置中使用了 mini-css-extract-plugin 是的 server bundle 中会使用到 document,node 环境中不存在 window 对象,所以报错。

3. SSR modOpt.store.registerModule is not a function
- 注册的模块代码格式不对
17 changes: 12 additions & 5 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
module.exports = {
presets: ['@vue/cli-plugin-babel/preset', '@babel/typescript'],
presets: [
'@vue/cli-plugin-babel/preset',
'@babel/preset-typescript'
// '@babel/typescript'
],
plugins: [
['@babel/plugin-proposal-decorators', { legacy: true }],
['@babel/plugin-proposal-class-properties', { loose: true }],
'@babel/plugin-proposal-object-rest-spread',
[
'import',
{
libraryName: 'vant',
libraryDirectory: 'es',
style: true,
style: true
},
'vant',
],
],
'vant'
]
]
};
Loading

0 comments on commit a33d191

Please sign in to comment.