build.sh 938 字节
Newer Older
1 2 3 4
#!/bin/bash

set -e

5 6 7 8
if [ -f "$HOME/.cargo/env" ]; then
    source $HOME/.cargo/env
fi

9
WORKING_PATH=`pwd`
10 11 12 13 14 15
SERVER_DIR="dist"
SERVER_DIR_PATH="$WORKING_PATH/$SERVER_DIR"
CLIENT_DIR="out"
CLIENT_DIR_PATH="$WORKING_PATH/$CLIENT_DIR"
OUTPUT="output"
OUTPUT_PATH="$WORKING_PATH/$OUTPUT"
16 17

# generate dist
18 19 20 21 22 23 24 25
rm -rf $SERVER_DIR_PATH
mkdir -p $SERVER_DIR_PATH
rm -rf $CLIENT_DIR_PATH
mkdir -p $CLIENT_DIR_PATH

# generate output
rm -rf $OUTPUT_PATH
mkdir -p $OUTPUT_PATH
26 27 28

# next build
yarn build:next
29

30 31 32 33
# server build
yarn build:server

# move static files
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
cp next.config.js $SERVER_DIR_PATH
cp package.json $SERVER_DIR_PATH

# package server files
(cd $SERVER_DIR_PATH && tar zcf $OUTPUT_PATH/server.tar.gz .)

# export
# WARNING: export LAST!!! dist files will be deleted by next after export
yarn export

# package client files
(cd $CLIENT_DIR_PATH && tar zcf $OUTPUT_PATH/client.tar.gz .)

# clean
rm -rf $SERVER_DIR_PATH
rm -rf $CLIENT_DIR_PATH