好用的前端库/包整理

Surge

Surge 是一个静态资源部署工具,支持一行命令部署静态资源到 project.surge.sh,只需要指定需部署的文件夹以及二级域名

1
2
3
4
5
6
7
8
9
10
// installation
npm install -g surge

// package.json
"scripts": {
"deploy": "surge /Users/xwill/learnCode/freeCode/vanilla xwillmadeit.surge.sh"
}

// deploy
npm run deploy

now

now 是 zeit 出品的命令行一键部署工具,支持部署 node 项目以及静态网站项目

1
2
// installation
npm i -g now

静态网站部署

在需要部署的目录(如 dist,有 index.html),直接执行 now 即可,每次部署会生成一个随机 url,类似于 https://dist-ktxztztigq.now.sh

node 项目部署(以 zeit 的 micro 为例)

参考官方

删除当前正在部署的进程

1
now rm app-name

修改 url

1
now alias https://dist-etjnigdrkz.now.sh hello

Tricks - 部署一个带有 Browser History 路由的 SPA

以 create-react-app 为例,执行构建后,会生成一个 build 文件夹,在 build 文件夹中执行

1
npm init -y

生成 package.json,修改相应的 package.json 信息,然后添加 scripts

1
2
3
"scripts": {
"start": "serve --single"
}

然后安装 serve

npm i -S serve

最后执行 now 即可