Set distDir
in next.config.js
module.exports = {
distDir: process.env.BUILD_DIR || '.next',
...
}
1
2
3
4
2
3
4
Deploy with this script:
echo "Deploy starting..."
git pull origin
yarn install || exit
BUILD_DIR=temp yarn build || exit
if [ ! -d "temp" ]; then
echo '\033[31m temp Directory not exists!\033[0m'
exit 1;
fi
rm -rf .next
mv temp .next
pm2 restart ecosystem.config.js
pm2 save
echo "Deploy done."
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Refs:
- https://nextjs.org/docs/api-reference/next.config.js/setting-a-custom-build-directory
Comment