Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support pwa in boilerplate template #262

Merged
merged 9 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ All notable changes to the create-aptos-dapp tool will be captured in this file.
# Unreleased

- [Fix] Generate Boilerplate template without Surf errors out because of a wrong file path
- Support PWA in the boilerplate template

# 0.0.36 (2024-10-28)

Expand Down
1 change: 1 addition & 0 deletions templates/boilerplate-template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ To get started with the Boilerplate template and learn more about the template f
- Aptos TS SDK
- Aptos Wallet Adapter
- Node based Move commands
- [Vite-pwa](https://vite-pwa-org.netlify.app/)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we add a section explaining the end user

  1. what is PWA briefly
  2. once they have the boilerplate generated locally, what should they do?
  3. how to deploy it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated doc on learn


## What Move commands are available?

Expand Down
1 change: 1 addition & 0 deletions templates/boilerplate-template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"typescript": "^5.2.2",
"vite": "^5.2.0",
"vite-plugin-notifier": "^0.1.5",
"vite-plugin-pwa": "^0.20.5",
"tree-kill": "1.2.2",
"dotenv": "16.3.1",
"vercel": "^35.2.4"
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 31 additions & 1 deletion templates/boilerplate-template/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import path from "path";
import react from "@vitejs/plugin-react";
import { defineConfig } from "vite";
import { VitePWA } from "vite-plugin-pwa";

export default defineConfig({
build: {
Expand All @@ -10,7 +11,36 @@ export default defineConfig({
open: true,
},
plugins: [
react()
react(),
VitePWA({
disable: false,
registerType: "autoUpdate",
manifest: {
name: "Aptos Fullstack Template",
short_name: "Aptos Template",
icons: [
{
src: "/icons/icon-192x192.png",
sizes: "192x192",
type: "image/png",
purpose: "any maskable",
},
{
src: "/icons/icon-384x384.png",
sizes: "384x384",
type: "image/png",
},
{
src: "/icons/icon-512x512.png",
sizes: "512x512",
type: "image/png",
},
],
start_url: "/",
display: "standalone",
orientation: "portrait",
},
}),
],
resolve: {
alias: {
Expand Down
1 change: 1 addition & 0 deletions templates/nextjs-boilerplate-template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ To get started with the Boilerplate template and learn more about the template f
- Aptos TS SDK
- Aptos Wallet Adapter
- Node based Move commands
- [Next-pwa](https://ducanh-next-pwa.vercel.app/)

## What Move commands are available?

Expand Down
37 changes: 37 additions & 0 deletions templates/nextjs-boilerplate-template/_gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Aptos related files
.aptos
.env
contract/build

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
build
dist-ssr
*.local
package-lock.json
pnpm-lock.yaml

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

# template related files
example-collection/

.next
14 changes: 9 additions & 5 deletions templates/nextjs-boilerplate-template/next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
import withPWAInit from "@ducanh2912/next-pwa";

const withPWA = withPWAInit({
disable: false,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this being used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed, it's default to public anyway

});

// Your Next config is automatically typed!
export default withPWA({
output: "export", // Outputs a Single-Page Application (SPA).
distDir: "./dist", // Changes the build output directory to `./dist/`.
basePath: process.env.NEXT_PUBLIC_BASE_PATH, // Sets the base path to `/some-base-path`.
};

export default nextConfig;
});
1 change: 1 addition & 0 deletions templates/nextjs-boilerplate-template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"dependencies": {
"@aptos-labs/ts-sdk": "^1.30.0",
"@aptos-labs/wallet-adapter-react": "^3.6.2",
"@ducanh2912/next-pwa": "^10.2.9",
"@radix-ui/react-collapsible": "^1.1.0",
"@radix-ui/react-dialog": "^1.1.1",
"@radix-ui/react-dropdown-menu": "^2.1.1",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion templates/nextjs-boilerplate-template/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import { TopBanner } from "@/components/TopBanner";
import "./globals.css";

export const metadata: Metadata = {
applicationName: "Aptos Boilerplate Template",
title: "NextJS Boilerplate Template",
description: "NextJS Boilerplate Template is a...",
description: "Aptos Boilerplate Template",
manifest: "/manifest.json",
};

export default function RootLayout({
Expand Down
25 changes: 25 additions & 0 deletions templates/nextjs-boilerplate-template/src/app/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "Aptos Fullstack Template",
"short_name": "Aptos Template",
"icons": [
{
"src": "/icons/icon-192x192.png",
"sizes": "192x192",
"type": "image/png",
"purpose": "any maskable"
},
{
"src": "/icons/icon-384x384.png",
"sizes": "384x384",
"type": "image/png"
},
{
"src": "/icons/icon-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
],
"start_url": "/",
"display": "standalone",
"orientation": "portrait"
}
Loading