Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
sho1374k committed Aug 4, 2023
0 parents commit 44d0f20
Show file tree
Hide file tree
Showing 55 changed files with 4,046 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# build output
dist/

# generated types
.astro/

# dependencies
node_modules/

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

# environment variables
.env
.env.production

# macOS-specific files
.DS_Store

package-lock.json

_bk
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package.json
package-lock.json
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"tabWidth": 2,
"trailingComma": "all",
"useTabs": false,
"semi": true,
"printWidth": 120
}
4 changes: 4 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"recommendations": ["astro-build.astro-vscode"],
"unwantedRecommendations": []
}
11 changes: 11 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"version": "0.2.0",
"configurations": [
{
"command": "./node_modules/.bin/astro dev",
"name": "Development server",
"request": "launch",
"type": "node-terminal"
}
]
}
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
}
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Toys.028 | WebGL Carousel Demo.06 ~ PaperAnimation

## 👾 ~ Demo

- https://dev.shoya-kajita.com/028/

<img src="public/assets/img/head/screenshot.webp">

<img src="screenshot2.webp">

## 🎮 ~ Getting Started

```
// install
npm i
// development
npm run dev
// production
npm run build
// build preview
npm run preview
```

## 📝 ~ Note

- https://www.pentacreation.com/blog/2021/06/210605.html
- https://tympanus.net/codrops/2020/01/22/how-to-unroll-images-with-three-js/
- https://tympanus.net/Development/UnrollingImages/
- https://github.com/akella/UnrollingImages/blob/master/js/shader/vertex.glsl

<img src="sample_sine.gif">
92 changes: 92 additions & 0 deletions astro.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import { defineConfig } from "astro/config";
import postcssMergeQueries from "postcss-merge-queries";
import htmlMinify from "@frontendista/astro-html-minify";
import glsl from "vite-plugin-glsl";
import sitemap from "@astrojs/sitemap";
import * as dotenv from "dotenv";
dotenv.config();

function createDate() {
const now = new Date(),
year = now.getFullYear(),
month = now.getMonth() + 1,
date = now.getDate(),
hour = now.getHours(),
minute = now.getMinutes();
return `${year}${month}${date}${hour}${minute}`;
// return `${year}${month}${date}`;
}

const DATE = createDate(),
MODE = process.env.NODE_ENV,
SITE_URL = MODE === "production" ? process.env.PUBLIC_PROD_URL : process.env.PUBLIC_LOCAL_URL;
// ? process.env.PUBLIC_TEST_URL : process.env.PUBLIC_LOCAL_URL;
// ? process.env.PUBLIC_LOCAL_URL : process.env.PUBLIC_LOCAL_URL;

console.log(
`// --------------------------\n\n⚡️ ~ MODE : ${MODE}\n\n▕▔▔▔▔▔▔▔▔▔▔▔╲\n▕╮╭┻┻╮╭┻┻╮╭▕╮╲\n▕╯┃╭╮┃┃╭╮┃╰▕╯╭▏\n▕╭┻┻┻┛┗┻┻┛ ╰▏ ▏\n▕╰━━━┓┈┈┈╭╮▕╭╮▏\n▕╭╮╰┳┳┳┳╯╰╯▕╰╯▏\n▕╰╯┈┗┛┗┛┈╭╮▕╮┈▏\n\n// --------------------------`,
);

console.log(SITE_URL);

// https://astro.build/config
export default defineConfig({
markdown: {
drafts: true,
},
build: {
assets: "assets",
},
site: SITE_URL,
base: "/",
vite: {
plugins: [glsl()],
esbuild: {
drop: ["console", "debugger"],
},
build: {
assetsInlineLimit: 0,
chunkSizeWarningLimit: 100000000,
rollupOptions: {
output: {
assetFileNames: `assets/[ext]/[name].${DATE}[extname]`,
entryFileNames: `assets/js/build.${DATE}.js`,
},
},
cssCodeSplit: false,
},
css: {
postcss: {
plugins: [postcssMergeQueries],
},
},
server: {
open: true,
port: 8080,
},
preview: {
open: true,
port: 8080,
},
},
integrations: [
sitemap(),
htmlMinify({
reportCompressedSize: false,
htmlTerserMinifierOptions: {
removeComments: true,
removeTagWhitespace: false,
},
}),
],
server: {
open: true,
host: true,
port: 3000,
},
preview: {
open: true,
host: true,
port: 3000,
},
});
30 changes: 30 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "project",
"type": "module",
"version": "0.0.1",
"scripts": {
"dev": "astro dev",
"start": "astro dev",
"build": "astro build && node replaceHtml.mjs",
"preview": "astro preview",
"astro": "astro"
},
"dependencies": {
"astro": "^2.2.1",
"gsap": "^3.11.4",
"three": "^0.148.0"
},
"devDependencies": {
"@astrojs/sitemap": "^1.2.2",
"@frontendista/astro-html-minify": "^1.0.7",
"autoprefixer": "^10.4.14",
"dotenv": "^16.0.3",
"fs-extra": "^11.1.1",
"glob": "^9.3.4",
"postcss-merge-queries": "^1.0.3",
"prettier": "^2.8.7",
"prettier-plugin-astro": "^0.8.0",
"sass": "^1.61.0",
"vite-plugin-glsl": "^1.1.2"
}
}
3 changes: 3 additions & 0 deletions postcss.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
plugins: [require("autoprefixer")],
};
Binary file added public/assets/img/head/apple-touch-icon.webp
Binary file not shown.
Binary file added public/assets/img/head/favicon.ico
Binary file not shown.
Binary file added public/assets/img/head/screenshot.webp
Binary file not shown.
Binary file added public/assets/img/head/thumbnail.webp
Binary file not shown.
Binary file added public/assets/video/movie1.mp4
Binary file not shown.
Binary file added public/assets/video/movie2.mp4
Binary file not shown.
Binary file added public/assets/video/movie3.mp4
Binary file not shown.
4 changes: 4 additions & 0 deletions public/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
User-agent: *
Allow: /

Sitemap: https://dev.shoya-kajita.com/sitemap-index.xml
50 changes: 50 additions & 0 deletions replaceHtml.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { writeFileSync, readFileSync } from "fs";
import glob from "glob";

const replaceInHtmlFiles = () => {
try {
const files = glob.sync("dist/**/*.html");
console.log(files);
for (const file of files) {
// htmlファイルの読み込み
const data = readFileSync(file, "utf8");

// htmlの置かれているパスから相対(., ..)を算出
let relativePath = file.replace(/[^/]/g, "").replace(/\//g, ".");

if (relativePath.length === 1) {
relativePath = file.replace(/[^/]/g, "").replace(/\//g, ".");
} else {
relativePath = file.replace(/[^/]/g, "").replace(/\//g, "../");
relativePath = relativePath.slice(0, -1);
// 3 ... | ../../ → ../..
// 4 .... | ../../../ → ../../..
// 5 ..... | ../../../../ → ../../../..
}

// href, srcに指定されている絶対パスを置換
const result = data
.replace(/href="\//g, `href="${relativePath}/`)
.replace(/href='\//g, `href='${relativePath}/`)
.replace(/src="\//g, `src="${relativePath}/`)
.replace(/src='\//g, `src='${relativePath}/`)
.replace(/srcset="\//g, `srcset="${relativePath}/`)
.replace(/srcset='\//g, `srcset='${relativePath}/`)
.replace(/action="\//g, `action="${relativePath}/`)
.replace(/action='\//g, `action='${relativePath}/`)
.replace(/content="\//g, `content="${relativePath}/`)
.replace(/content='\//g, `content='${relativePath}/`);

writeFileSync(file, result, "utf8");
// console.log(file);
}
console.log(`\n// --------------------------\n\n👌 ~ replaceInHtmlFiles\n\n// --------------------------\n`);
} catch (error) {
console.log(
`\n// -------------------------- \n\n🙅‍♀️ ~ replaceInHtmlFiles\n\n// --------------------------\n${error}\n`,
);
}
};

replaceInHtmlFiles();
// node replaceHtml.mjs
Binary file added sample_sine.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshot2.webp
Binary file not shown.
Loading

0 comments on commit 44d0f20

Please sign in to comment.