fix: добавить postbuild.js для копирования статических файлов
- scripts/postbuild.js: новый скрипт для копирования public и .next/static в .next/standalone - package.json: запуск postbuild.js после npm run build - scripts/install.sh: использование postbuild.js вместо ручного копирования - scripts/manage.sh: использование postbuild.js вместо ручного копирования - next.config.js: убран outputFileTracingRoot (не работает в Next.js 16) Теперь стили и статические файлы должны корректно работать в продакшене
This commit is contained in:
@@ -191,30 +191,16 @@ case "$1" in
|
||||
echo -e "${RED}The .next/standalone directory will not be created if the build fails.${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure public directory and static files are accessible in standalone build
|
||||
echo -e "${YELLOW}Setting up static files...${NC}"
|
||||
if [ -d "$INSTALL_DIR/.next/standalone" ]; then
|
||||
# Copy public directory to standalone (always update)
|
||||
if [ -d "$INSTALL_DIR/public" ]; then
|
||||
echo -e "${YELLOW}Copying public directory to standalone...${NC}"
|
||||
rm -rf "$INSTALL_DIR/.next/standalone/public" 2>/dev/null || true
|
||||
cp -r "$INSTALL_DIR/public" "$INSTALL_DIR/.next/standalone/public" 2>/dev/null || true
|
||||
fi
|
||||
# Copy .next/static to standalone/.next/static (always update)
|
||||
if [ -d "$INSTALL_DIR/.next/static" ]; then
|
||||
echo -e "${YELLOW}Copying .next/static to standalone...${NC}"
|
||||
rm -rf "$INSTALL_DIR/.next/standalone/.next/static" 2>/dev/null || true
|
||||
mkdir -p "$INSTALL_DIR/.next/standalone/.next"
|
||||
cp -r "$INSTALL_DIR/.next/static" "$INSTALL_DIR/.next/standalone/.next/static" 2>/dev/null || true
|
||||
else
|
||||
echo -e "${RED}Warning: .next/static directory not found!${NC}"
|
||||
fi
|
||||
|
||||
# Post-build script already copies public and .next/static to standalone directory
|
||||
# Just verify the files are in place
|
||||
echo -e "${YELLOW}Verifying standalone build...${NC}"
|
||||
if [ -d "$INSTALL_DIR/.next/standalone/public" ] && [ -d "$INSTALL_DIR/.next/standalone/.next/static" ]; then
|
||||
echo -e "${GREEN}✓ Static files are in place${NC}"
|
||||
else
|
||||
echo -e "${RED}Error: .next/standalone directory not found!${NC}"
|
||||
echo -e "${RED}This usually means the build failed or output: 'standalone' is not configured correctly.${NC}"
|
||||
echo -e "${RED}Please check next.config.js and ensure the build completed successfully.${NC}"
|
||||
exit 1
|
||||
echo -e "${RED}Warning: Static files may be missing from standalone directory${NC}"
|
||||
echo -e "${YELLOW}Running post-build script manually...${NC}"
|
||||
node scripts/postbuild.js || true
|
||||
fi
|
||||
|
||||
# Set ownership
|
||||
|
||||
Reference in New Issue
Block a user