# @ruiyun/preact-multi-page-template

> ``` yarn yarn start ``` 之后访问http://{本机ip}:3000就可以看到页面

Latest version **1.2.20** (published 2019-08-04) · ISC license · 0 weekly downloads

## Install

```sh
npm install @ruiyun/preact-multi-page-template
pnpm add @ruiyun/preact-multi-page-template
yarn add @ruiyun/preact-multi-page-template
bun add @ruiyun/preact-multi-page-template
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.20 |
| Published | 2019-08-04 |
| First published | 2019-05-14 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 17 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | wen911119 |

## Links

- npm: https://www.npmjs.com/package/@ruiyun/preact-multi-page-template
- npm.io page: https://npm.io/package/@ruiyun/preact-multi-page-template

## Dependencies (2)

- [preact](https://npm.io/package/preact.md) ^10.0.0-beta.3
- [@ruiyun/preact-m-nav](https://npm.io/package/@ruiyun/preact-m-nav.md) ^1.2.7

## Recent versions

- 1.2.20 (latest) — 2019-08-04
- 1.2.19 — 2019-08-02
- 1.2.18 — 2019-08-02
- 1.2.16 — 2019-08-02
- 1.2.9 — 2019-07-19
- 1.2.8 — 2019-07-18
- 1.2.7 — 2019-07-09
- 1.2.5 — 2019-06-28
- 1.2.3 — 2019-06-17
- 1.2.2 — 2019-06-17
- 1.2.1 — 2019-06-11
- 1.2.0 — 2019-06-11
- 1.1.34 — 2019-06-06
- 1.1.33 — 2019-06-06
- 1.1.29 — 2019-05-20
- … 8 more at https://npm.io/package/@ruiyun/preact-multi-page-template/versions

## README

### 快速开始
```
yarn
yarn start
```
之后访问http://{本机ip}:3000就可以看到页面

### 快速创建页面
```
yarn add-page
```
会依次提示你输入页面名（英文页面名）和页面标题（会显示在标题栏），之后会帮你创建好h5页面和小程序页面。
同时会在package.json中增加pages属性记下页面名和标题的对应关系。

### 构建目标全局变量
```javascript
console.log($BUILD_TARGET$)
// 本地开发(yarn start) ==> local
// 测试环境(yarn build:dev) ==> dev
// 生产环境(yarn build:pro) ==> production
```
可以根据不同值来走不同api的endpoint

### 修改响应式基础
默认是按照移动端750px的设计的，如果要修改，可以在package.json里加一个属性p2rBase，值改为设计稿尺寸，比如1080。

### 修改默认页面模版
可以在项目根目录下放一个自定义的template.html

### 提取公文js库进common.js
package.json中有一个commonChunks属性，里面记录了要进common.js的包名。

### 自定义entry
#### 方式一:
在/src/下建立一个entry.js,写入
```javascript
export default function onEntry () {
  // 下面的代码每个页面初始化时都会执行
  console.log('hhh')
}
```
这个onEntry函数每个页面初始化都会执行。
#### 方式二:
在 src/pages/{页面名}/ 下建立entry.js,写入
```javascript
export default function onEntry () {
  // 下面的代码只有该页面初始化时会执行
  console.log('dddd')
}
```
这个onEntry函数只有这个页面初始化时才会执行。
方式二的entry会覆盖方式一。

### 自定义兼容性
默认的js和css兼容性是“last 2 versions”。如果不满足你的需要，可以在package.json中加入
```json
{
  "browsers": [
    "android >= 4.4",
    "ios >= 8"
  ]
}
```
可以参考[browserl.ist](https://browserl.ist/)来设置你想要的兼容性。

### 自定义后编译的包
默认只会编译src下面的js文件。但是有些npm包是需要编译后再使用的(个人推荐这种方式),比如@ruiyun/preact-m-nav,@ruiyun/preact-layout-suite等。可以在package.json中加入
```json
{
  "include": [
    "@ruiyun",
    "p-to-r",
    "h5-indicator"
  ],
}
```
来自定义加入需要后编译的包名。

---
_Source: https://npm.io/package/@ruiyun/preact-multi-page-template · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
